Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt 3 doesn't load named routes from nuxt.config.ts #13373

Closed
tiborpino opened this issue Feb 11, 2022 · 4 comments
Closed

Nuxt 3 doesn't load named routes from nuxt.config.ts #13373

tiborpino opened this issue Feb 11, 2022 · 4 comments

Comments

@tiborpino
Copy link

tiborpino commented Feb 11, 2022

Environment

  • Operating System: Darwin
  • Node Version: v14.18.0
  • Nuxt Version: 3.0.0-27408103.b243891
  • Package Manager: yarn@1.22.11
  • Bundler: Vite
  • User Config: vue, modules, buildModules, build, css, app, meta, publicRuntimeConfig, privateRuntimeConfig, router
  • Runtime Modules: @nuxtjs/sitemap@2.4.0
  • Build Modules: nuxt-purgecss@1.0.0

Reproduction

nuxt.config.ts

export default defineNuxtConfig({ router: { routes: [ { path: '/login', name: 'LoginPage', }, ], }, })

*.vue

<NuxtLink :to="{ name: 'LoginPage' }">link</NuxtLink>

Describe the bug

  1. Define named router.routes: [] in nuxt.config.ts
  2. Use named routes in *vue via NuxtLink
  3. There is an error: No match for {"name":"LoginPage","params":{}}

Additional context

No response

Logs

No match for
 {"name":"LoginPage","params":{}}
  at createRouterError (./node_modules/vue-router/dist/vue-router.cjs.js:827:23)  
  at Object.resolve (./node_modules/vue-router/dist/vue-router.cjs.js:1406:23)  
  at Object.resolve (./node_modules/vue-router/dist/vue-router.cjs.js:2897:38)  
  at ReactiveEffect.fn (./node_modules/vue-router/dist/vue-router.cjs.js:2048:45)  
  at ReactiveEffect.run (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:150:25)  
  at ComputedRefImpl.get value [as value] (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:1090:39)  
  at ReactiveEffect.fn (./node_modules/vue-router/dist/vue-router.cjs.js:2050:35)  
  at ReactiveEffect.run (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:150:25)  
  at ComputedRefImpl.get value [as value] (./node_modules/@vue/reactivity/dist/reactivity.cjs.js:1090:39)  
  at ReactiveEffect.fn (./node_modules/vue-router/dist/vue-router.cjs.js:2075:64)
@tiborpino tiborpino changed the title Nuxt 3 doesn't laod named routes from nuxt.config.ts Nuxt 3 doesn't load named routes from nuxt.config.ts Feb 11, 2022
@danielroe
Copy link
Member

Nuxt 3 doesn't support configuration of the router via nuxt.config at all. Instead, use the extendPages function in a module or use the pages:extend hook.

@tiborpino
Copy link
Author

tiborpino commented Feb 12, 2022

But there is a property router.routes on nuxt.config. What's the purpose of the property?

@tiborpino
Copy link
Author

tiborpino commented Feb 12, 2022

Is there a documentation for extendPages or pages:extend?

@danielroe
Copy link
Member

But there is a property router.routes on nuxt.config. What's the purpose?

This is a Nuxt 2 property. This should be displayed in your IDE with the @version 2 tag. We're working on making this not show up at all in Nuxt 3 projects 🤞

Not yet - but there should be! I've created #13381 and https://github.com/nuxt/framework/issues/3210 to track.

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants