How can I set multiple path for 1 page in NextJS pages directory?

I have a project with 2 different themes. And I can switch themes with environment. Its all works perfectly but for paths, some pages should open same page with different paths. For example ;

For open contact page i normally using /contact path.

But if I switch theme from environment and restart project, /contact page shouldn’t work and instead of /contact, I want to use /iletisim path for open exact same page.
And my some of pages is like /contact/[…contact-detail-item]. How can i handle it too ?
Thanks for all helps!

Versions: NextJS 13 Pages Directory.

There is no reason why some page should be reached by more than one path. Pages and paths have a “one-to-one” relation, and you are writing doubled code at your backend if two routes “open the exact same page”, as you wrote.

Also, change “themes” like light/dark are frontend issues; the data your server provided when queried for the “/contacts” path is not theme-dependable.

If the answer didn’t help, please add more details about your problem

Leave a Comment