Search code examples
next.jsdynamic-routing

How to create a dynamic route in Next.js


How can I create this type of url :

http://localhost:3000/designer/book1

http://localhost:3000/engeniring/book1

http://localhost:3000/art/book1

If I try to put files in specific name in pages folder, Then I have to do that multiple time.

Any idea?

Here desinger, enginerring, art are dynamic like book category and book1 are also dynamic is act like a single post


Solution

  • You could set up the folder structure for nested dynamic routes

    Something like this:

    enter image description here

    And then have your nesting routes inside.

    Here is a live example for that