Search code examples
vue.jsnuxt.jsnuxt3.js

Can I use nuxt3 without router when I'm only generating one static page?


I've noticed that in Nuxt 3 there is one app.vue file, and you can create a ./pages/index.vue file, but if I'm only generating one static index page, can I just remove the vue-router and the ./pages/index.vue?


Solution

  • Yes, you can keep your code in a single file as officially stated here.

    Nuxt 3 ships with an optional vue-router integration triggered by the existence of a pages/ directory in your source directory. If you only have a single page, you may consider instead moving it to app.vue for a lighter build.

    You don't need to actually remove anything, if there is no pages/ directory vue-router will not get imported in the bundle of your project.