Next.js Discord

Discord Forum

Multiple dynamic routes in the same route folder

Answered
Morelet’s Crocodile posted this in #help-forum
Open in Discord
Morelet’s CrocodileOP
I'm running into trouble with the App Router & dynamic routes. My blog directory needs to have a catch-all route for the posts, a main /blog page (currently shown in /archive for demo purposes), and a paginated route under /page (eg. /page/2, /page/3, and so on).

What's got me confused is that when navigating to my test route of /blog/archive, the matching page.js file is loading just fine, but when I navigate to /blog/page/2, I'm getting an error that's referencing the /blog/[...slug]/page.js route file instead of the page file under /blog/page.

Is this expected behavior? Still trying to wrap my head around multiple dynamic routes under the same top level route folder.
Answered by Morelet’s Crocodile
Now realizing that the proper structure is /blog/page/[page]/page.js.

Nothing to see here. Move along.
View full answer

1 Reply

Morelet’s CrocodileOP
Now realizing that the proper structure is /blog/page/[page]/page.js.

Nothing to see here. Move along.
Answer