Next.js Discord

Discord Forum

Dynamic route based of path condition

Answered
gin posted this in #help-forum
Open in Discord
ginOP
Yo i wanted to know if its possible to render a different route based of the pathname. Example:
i have
domain.com/blog
but i can also have
domain.com/@gin
Answered by riský
just simply having /blog/page.tsx and then /[yes]/page.tsx would work as dynamic route has lowest pirority
View full answer

6 Replies

ginOP
can nextjs recognize this or do i have to wrap all the routes inside one handler (i dont want to do this)
just simply having /blog/page.tsx and then /[yes]/page.tsx would work as dynamic route has lowest pirority
Answer
and then if it isnt starting with @ and not there, can just notfound anyway
the other option would be to use nextjs rewrites and detect with starting with /@ and then go to your page with still a dynamic route
@gin thanks
np! enjoy your app building