Cranwell
Cranwell

Reputation: 37

How to create dynamic route in Nuxt?

By default, nuxt adds a route for each page in pages.

I want to make when going to the page e.g. project.local/id/ec29cjsa5fas512ik, the user goes to a page template and the Vue receives this ec29cjsa5fas512ik id from the url so it can make proper API calls later.

Upvotes: 1

Views: 727

Answers (1)

kissu
kissu

Reputation: 46814

You can make a dynamic page in Nuxt2 with the following file, eg.

/pages/details/_id.vue

then you'll have a path like /details/:id.


More info can be found here: https://nuxtjs.org/docs/features/file-system-routing#dynamic-routes

Upvotes: 2

Related Questions