Next.js Discord

Discord Forum

How can i make optional routes?

Unanswered
Large Münsterländer posted this in #help-forum
Open in Discord
Large MünsterländerOP
I mean, imagine i have a route like /user/[id], so now i want to make an exact route called /u/[id] which renders the first route without having to copypaste it

1 Reply

you can use rewrites to map the /u/[id] route to the existing /user/[id] page: https://nextjs.org/docs/app/api-reference/next-config-js/rewrites