2

I want to create dynamic pages in nextjs to match the following route users/[user]/[dashboard]. My file structure

pages/
 users/
  -[user].js       // will match for /users/123
  - index.js        // will match for /users
    dashboard/
      - [dashboard].js   // will match for /users/1234/ABCD

I'm only receiving the [user] in the query param and not the [dashboard] inside the [dashboard].js . Can someone explain how to arrange file structure to match users/[user]/[dashboard]

1 Answer 1

9

To match the following dynamic routes users/[user]/[dashboard] you can structure your pages folder as follows:

pages/
  users/      
    index.js        // Matches `/users` route
    [user]/   
      index.js      // Matches `/users/user123` routes
      [dashboard]/
        index.js    // Matches `/users/user123/dashboardABC` routes
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.