Skip to content

fix(pages-router): preserve dynamic href history state - #3368

Open
james-elicx wants to merge 1 commit into
codex/pages-router-url-normalizationfrom
codex/pages-router-dynamic-history
Open

james-elicx wants to merge 1 commit into
codex/pages-router-url-normalizationfrom
codex/pages-router-dynamic-history

Conversation

@james-elicx

@james-elicx james-elicx commented Sep 22, 2026

Copy link
Copy Markdown
Member

Depends on #3367. This is the last of three cohesive Pages Router PRs for #3351; review #3354, then #3367, then this PR.

Review map

  • shims/router.ts and internal/pages-data-target.ts: keep route-pattern identity, visible URL, data-fetch target, middleware probe, and history state distinct through push, replace, and popstate. Preserve same-origin absolute href, basePath, locale, relative paths, and dynamic/static collisions. Initial dynamic GSSP history retains browser search keys, with route params taking precedence.
  • entries/pages-client-entry.ts, server/dev-server.ts, server/pages-dev-hydration.ts, index.ts: match dev page loaders, data-kind/middleware manifests, and HMR behavior to production navigation. Lazy page URLs are imported at runtime so unrelated pages are not HMR dependencies of every hydration proxy; the initial page retains its bare module identity. Qualify runtime imports with Vite’s BASE_URL for basePath projects, without appending a duplicate ?import. Vite inline HTML proxies are invalidated after classification changes.
  • Focused Pages tests/fixtures: initial history, away/back query preservation, middleware, dynamic routes, dev/prod hydration, GSP/GSSP, browser navigation, MDX lazy loading, and a direct unrelated-page HMR dependency-graph regression. Most added lines are parity tests, not runtime abstractions.

Next.js references

Validation

Locally on 9344c72e049d93af0eb38f318313ee781e93125c: 1,432 focused unit tests, HMR graph and custom-error integration tests, seven hydration browser tests (including MDX), and all three basePath-dev browser tests passed on fresh isolated servers. vp check and vp run vinext#build passed. Fresh independent parity and maintainability reviews found no actionable in-scope issues. Exact-head CI and Big Bonk are still running; this PR remains draft until clean.

@james-elicx
james-elicx added this pull request to stack #3369 September 22, 2026 10:34
@james-elicx

Copy link
Copy Markdown
Member Author

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

@pkg-pr-new

pkg-pr-new Bot commented Sep 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/@vinext/cloudflare@3368

create-vinext-app

npm i https://pkg.pr.new/create-vinext-app@3368

@vinext/types

npm i https://pkg.pr.new/@vinext/types@3368

vinext

npm i https://pkg.pr.new/vinext@3368

@cloudflare/workers-response-store

npm i https://pkg.pr.new/@cloudflare/workers-response-store@3368

commit: 9344c72

Comment thread packages/vinext/src/shims/router.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@github-actions

Copy link
Copy Markdown
Contributor
Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original
response-store-demo preview production
workers-cache preview production
kv preview production
static-export preview production
web preview production

@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared 9344c72 against base 6b1d5f7 using alternating same-runner rounds. Next.js was unchanged and skipped.

1 improved · 0 regressed · 5 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 142.3 KB 142.3 KB ⚫ +0.0%
Client entry size (gzip) vinext 130.4 KB 130.4 KB ⚫ +0.0%
Dev server cold start vinext 3.32 s 3.31 s ⚫ -0.2%
Production build time vinext 3.87 s 3.80 s 🟢 -1.7%
RSC entry closure size (gzip) vinext 127.5 KB 127.9 KB ⚫ +0.3%
Server bundle size (gzip) vinext 225.8 KB 226.3 KB ⚫ +0.2%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@james-elicx
james-elicx force-pushed the codex/pages-router-dynamic-history branch from 97bb7dd to d981a07 Compare September 22, 2026 10:48
@james-elicx

Copy link
Copy Markdown
Member Author

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Comment thread packages/vinext/src/shims/router.ts
@james-elicx

Copy link
Copy Markdown
Member Author

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx
james-elicx force-pushed the codex/pages-router-dynamic-history branch from 7e9de6a to 818cda7 Compare September 22, 2026 10:57
@james-elicx

Copy link
Copy Markdown
Member Author

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

@james-elicx
james-elicx force-pushed the codex/pages-router-dynamic-history branch from 818cda7 to e633400 Compare September 22, 2026 11:01
Comment thread packages/vinext/src/shims/router.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx
james-elicx force-pushed the codex/pages-router-dynamic-history branch from e633400 to 5bd2ed8 Compare September 22, 2026 11:02
@james-elicx

Copy link
Copy Markdown
Member Author

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/index.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/index.ts
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/server/dev-server.ts
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/shims/router.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/index.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/server/pages-dev-hydration.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/server/pages-dev-hydration.ts Outdated
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/server/pages-dev-hydration.ts
@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline finding.

github run

@james-elicx

Copy link
Copy Markdown
Member Author

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants