1

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.

Cranwell
  • 37
  • 7
  • Something like this? https://stackoverflow.com/a/67490633/8816585 Nuxt's dynamic route + accessing `this.$route.params`. – kissu Nov 21 '22 at 12:24
  • 1
    Exactly! Nuxt's dynamic routes allows to make /page/:id thing with just an underscore in the beggining. Thanks – Cranwell Nov 21 '22 at 12:30

1 Answers1

2

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

kissu
  • 40,416
  • 14
  • 65
  • 133