Languages
[Edit]
EN

Nuxt 3 - add pages

0 points
Created by:
Mariam-Barron
811

In this article, we would like to show you how to add pages in Nuxt 3.

1. Modify project structure

In order to create new pages / routing in your project, you need to modify the project structure to have all the pages inside one directory.

  1. Create new pages/ folder in the root directory. From now, inside the pages/ folder you can create different files, where each file represents a different page (route).
  2. Rename app.vue file to index.vue and move it into the pages/ folder. From now pages/index.vue file will represent the home page of your application with the '/' route.

2. Creating new pages (routes)

Inside the pages/ folder you can create different files where each file would represent a different page and route. Nuxt 3 will automatically set the route to the file name.

3. Practical example

Creating about.vue component inside this pages/ folder, would create a route for this page which would just be /about (http://localhost:3000/about).

VS Code preview:

Nuxt 3 - creating new pages in project

Web browser preview:

Nuxt 3 - creating new routes in project

Alternative titles

  1. Nuxt 3 - add new routes / pages in project
  2. Nuxt 3 - creating new pages in project
  3. Nuxt 3 - creating routing in project
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join