You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
typedPages: useRoute() type falls back to keyof RouteNamedMap when process.cwd() !== rootDir #35564
1-regular-flow — nuxt.config.ts + package.json in one dir (cwd === rootDir) → useRoute() typing works
2-bug-subdir — nuxt.config.ts in a subdir prepared with --cwd (cwd !== rootDir) → typing breaks (vue-tsc errors)
3-patched-subdir — same layout + the one-line fix → works
Describe the bug
With experimental.typedPages, the sfc-typed-router Volar plugin rewrites a bare useRoute() in a page to useRoute<_RouteNamesForFilePath<'<file>'>>(), so route.name is inferred as that page's route name.
This silently breaks whenever Nuxt is prepared with process.cwd() different from nuxt.options.rootDir — e.g. a Nuxt app in a subdirectory prepared via nuxt <cmd> --cwd <subdir> from a parent directory (common in monorepos; --cwd sets rootDir but not the OS process.cwd()). useRoute().name then degrades to the full keyof RouteNamedMap union.
Root cause
packages/nuxt/src/pages/module.ts builds the typed-router context without a root:
resolveOptions (from vue-router/unplugin) defaults root to process.cwd(), so the _RouteFileInfoMap keys in .nuxt/types/typed-router.d.ts are generated relative to process.cwd(). But the Volar plugin is registered with options: { rootDir: nuxt.options.rootDir } and resolves files via relative(rootDir, file). When the two bases differ, no key matches and _RouteNamesForFilePath<…> falls back to keyof RouteNamedMap.
The plugin always queries relative(rootDir, file) = app/pages/index.vue, so only the rootDir-relative keys match.
Fix
Pass root: nuxt.options.rootDir into typedRouterOptions so the DTS keys and the Volar plugin both use rootDir, regardless of process.cwd(). A PR follows.
#35036 - fix(nuxt): render component-less parent routes during client-side nav [merged] #35383 - perf(nuxt): reduce dev pages startup work [merged] #35408 - fix(nuxt): ensure page:start finishes before page:finish starts [merged] #35440 - fix(nuxt): avoid syncing route too early when reused page remounts [merged] #35442 - fix(nuxt): restore deferred query route before page is mounted [merged]
📝 Issue Planner
Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.
Create Plan
🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your .coderabbit.yaml:
issue_enrichment:
auto_enrich:
enabled: false
💬 Have feedback or questions? Drop into our discord!
Activity
coderabbitai commentedon Jul 14, 2026
🔗 Related PRs
#35036 - fix(nuxt): render component-less parent routes during client-side nav [merged]
#35383 - perf(nuxt): reduce dev pages startup work [merged]
#35408 - fix(nuxt): ensure
page:startfinishes beforepage:finishstarts [merged]#35440 - fix(nuxt): avoid syncing route too early when reused page remounts [merged]
#35442 - fix(nuxt): restore deferred query route before page is mounted [merged]
📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!