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]
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With