fix(router): useRouter().push/replace/navigate do SPA navigation (no full reload) - #3075
Merged
Conversation
…navigator The hydration runtime wired <Link> clicks to navigateSPA but never registered a navigator against the shared navigation store that RouterProvider reads, so useRouter().push()/replace()/navigate() fell through to location.assign() — a full document reload — in both the app and pages routers, while <Link> stayed SPA. Register navigateSPA as the store's navigator so programmatic navigation is SPA too. Export getNavigationStore from the react runtime and import it in both the dev (dev-client-renderer) and prod (prod-scripts) hydration module builders so the generated runtime can reach it. Refs veryfront/veryfront-issue-inbox#200 (finding 7)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf2abfdb06
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…est-typecheck gate The lint:test-typecheck baseline runs deno check on test files; RuntimeHandle.win omitted `location`, so `runtime.win.location.pathname = …` was a TS2339. Widen the type. Behavior unchanged (test still green).
The SPA navigator previously used one boolean for both replace and history-free navigation. Carry an explicit history mode so push, replace, and popstate paths preserve their distinct browser-history contracts. Constraint: useRouter replace must stay within the SPA while updating the visible URL. Rejected: Treat replace as history-free navigation | leaves the rendered route and browser URL out of sync. Confidence: high Scope-risk: narrow Tested: Generated router runtime regression; format; lint; typecheck Not-tested: Browser e2e navigation suite
kojiwakayama
enabled auto-merge
July 24, 2026 18:31
kojiwakayama
approved these changes
Jul 24, 2026
kwakayama
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
useRouter().push()/replace()/navigate()triggered a full document reload (destroying the JS realm) in both the app-router and pages-router, while<Link>correctly stayed SPA.The hydration runtime wires
<Link>clicks to itsnavigateSPA, but never registered a navigator against the shared navigation store thatRouterProviderreads — so the store'snavigatefell back tolocation.assign(href). This registersnavigateSPAas the store's navigator (mappinghistory: 'push' | 'replace'), so programmatic navigation is SPA too.getNavigationStoreis exported from the react runtime and imported by both the dev (dev-client-renderer) and prod (prod-scripts) hydration-module builders so the generated runtime can reach it.How to test
window.__spa = Date.now()), then triggeruseRouter().push('/other').<Link>navigation is unchanged (still SPA).deno test src/html/hydration-script-builder/— newrouter-push-spa.test.ts(red→green); all 12 files green.Refs veryfront/veryfront-issue-inbox#200 (finding 7)