Next.js Discord

Discord Forum

Multiple routes, one directory

Unanswered
Bombay-duck posted this in #help-forum
Open in Discord
Avatar
Bombay-duckOP
As the title states, is it possible to have multiple routes use the same route folder in /app?

Currently I've got profiles/[id]/page.tsx, but i also want the route vanity/[id] to use the same page.tsx as the first one.
Is this possible to do?

Both profiles/[id]/ and vanity/[id]/ should use the same directory and route files.

Sincerely, zwolof

3 Replies

Avatar
Bombay-duckOP
Got it working
By using a custom handler
Avatar
Wood Thrush
There are two advanced routing patterns which you can use if it fits: https://nextjs.org/docs/app/building-your-application/routing#advanced-routing-patterns
That way you get first class support without using anything of your own custom solution.