diff --git a/packages/nuxt/src/pages/module.ts b/packages/nuxt/src/pages/module.ts index b4e5fe7bee..38d5d91353 100644 --- a/packages/nuxt/src/pages/module.ts +++ b/packages/nuxt/src/pages/module.ts @@ -162,6 +162,11 @@ export default defineNuxtModule({ getContents: () => 'export { useRoute } from \'vue-router\'' }) + // Optimize vue-router to ensure we share the same injection symbol + nuxt.options.vite.optimizeDeps = nuxt.options.vite.optimizeDeps || {} + nuxt.options.vite.optimizeDeps.include = nuxt.options.vite.optimizeDeps.include || [] + nuxt.options.vite.optimizeDeps.include.push('vue-router') + // Add router options template addTemplate({ filename: 'router.options.mjs',