Repository navigation
fix(nuxt): restore deferred query route before page is mounted - #35442
Merged
danielroe merged 5 commits intoJun 25, 2026
Merged
Conversation
When hydrating a prerendered page whose URL carries a query, the route is kept query-less for the hydration render (to match the prerendered markup). The real route was only restored in `app:suspense:resolve`, which runs after the page's `onMounted`, so `useRoute().query` was empty in `onMounted` and script setup on prerendered pages. Restore the route as `<NuxtPage>`'s `Suspense` resolves — synchronously, before mounted hooks flush — so the query is present in `onMounted`, while the hydration render itself stays query-less and no hydration mismatch is reintroduced. Falls back to `app:suspense:resolve` when no page is rendered. Resolves nuxt#34651
This comment has been minimized.
This comment has been minimized.
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
Merging this PR will degrade performance by 10.59%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | loadNuxt in the basic test fixture (dev) |
325.8 ms | 364.3 ms | -10.59% |
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/prerender-query-restore-before-mount (a5b7532) with main (4909725)
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
danielroe
pushed a commit
that referenced
this pull request
Jun 25, 2026
Closed
This was referenced Jun 28, 2026
This was referenced Jul 8, 2026
danielroe
pushed a commit
that referenced
this pull request
Jul 15, 2026
Merged
This was referenced Jul 16, 2026
danielroe
pushed a commit
that referenced
this pull request
Jul 17, 2026
Merged
Ibochkarev
pushed a commit
to translation-gang/nuxt
that referenced
this pull request
Jul 24, 2026
This was referenced Jul 29, 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.
🔗 Linked issue
Resolves #34651
📚 Description
On a prerendered (SSG) page whose URL carries a query (e.g.
/products?active=true), Nuxt hydrates against the query-less prerendered markup and restores the real route afterwards. That restore ran in theapp:suspense:resolvehook, which fires after the page'sonMounted, souseRoute().querywas still empty duringonMounted(and<script setup>). This broke common patterns such as reading the query on mount.<NuxtPage>'sSuspenseonResolveruns synchronously when the page resolves — before the buffered mounted hooks flush. We restore the real route there instead:router.currentRouteis set synchronously (then history/URL are reconciled viarouter.replace) so the query is present inonMounted, while the hydration render itself stays query-less (no hydration mismatch). When no<NuxtPage>is rendered, it falls back toapp:suspense:resolveas before.