As we may know, Nuxt.js generates its routes by default based on the file structure of the pages folder.
What I want to know is, how to use a file and put my routes by myself, manually, instead of have Nuxt.js generating them for me?
Why?
I want more control of my routes, more explicit code and less files on the project.
I think its more easy to setup route params defining them explicit into a routes.js file rather then setting them by adding files into the project.
Any idea of how to do that, like on a normal Vue App? Thanks.
<nuxt-link> is essentially <router-link> of Vue Router. You can disable it using the event prop.
Vue 3 and Vite SupportWith Nuxt 3 being written in Vue 3, you get access to features like the Composition API, better module imports, and overall improved app performance. Nuxt 3 also comes with Vite support, which is backwards compatible with Nuxt 2.
Nuxt automatically generates the vue-router configuration for you, based on your provided Vue files inside the pages directory. That means you never have to write a router config again! Nuxt also gives you automatic code-splitting for all your routes.
You can use @nuxtjs/router for that https://www.npmjs.com/package/@nuxtjs/router
Another option is to enchance automatic routing with https://github.com/nuxt-community/router-extras-module
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With