Repository navigation
fix(nuxt): avoid syncing route too early when reused page remounts - #35440
Merged
Merged
Conversation
When a leaf component is reused across a navigation, the router plugin syncs the internal route immediately so that `useRoute` updates even though no Suspense boundary resolves. This is only correct when the page key is unchanged. For catch-all and param routes the key changes, the page remounts, and Suspense resolves after the new page is ready, so the immediate sync updates the route before the page content has changed. Only sync eagerly when the generated route key is unchanged; otherwise let `<NuxtPage>`'s `Suspense.onResolve` sync the route once the new page has resolved. Resolves nuxt#33107
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
This comment has been minimized.
This comment has been minimized.
Merging this PR will degrade performance by 11.19%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | loadNuxt in the basic test fixture (dev) |
331.7 ms | 373.5 ms | -11.19% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing raminjafary:fix/route-sync-reused-page (8c607fa) with main (91cb2fe)
Footnotes
-
3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
danielroe
approved these changes
Jun 25, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Jun 25, 2026
danielroe
pushed a commit
that referenced
this pull request
Jun 25, 2026
…35440) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Closed
This was referenced Jul 8, 2026
danielroe
pushed a commit
that referenced
this pull request
Jul 15, 2026
…35440) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Merged
danielroe
pushed a commit
that referenced
this pull request
Jul 17, 2026
…35440) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Merged
This was referenced Jul 18, 2026
Ibochkarev
pushed a commit
to translation-gang/nuxt
that referenced
this pull request
Jul 24, 2026
…uxt#35440) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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.
🔗 Linked issue
Resolves #33107
📚 Description
When a leaf component is reused across a navigation, the router plugin syncs the internal
_routeimmediately souseRouteupdates even though no<Suspense>boundary resolves (added in #34918 for navigating up the route tree).That is only correct when the page key is unchanged. For catch-all and param routes (e.g.
/items/1→/items/2) the key changes,<NuxtPage>remounts the page, andSuspense.onResolvesyncs the route once the new page has resolved — so the eager sync updatesuseRoute()before the page content has changed.This gates the eager sync on the generated route key being unchanged; when it changes, the (delayed, correct)
Suspense.onResolvesync is left to do the work.Added two runtime tests: one asserting the route read outside
<NuxtPage>does not update before a param navigation to the same component resolves, and one asserting a query-only navigation (same key, no remount) still syncs immediately (guards #34918).