Next.js Discord

Discord Forum

I am looking for support over routing.

Unanswered
Mallow bee posted this in #help-forum
Open in Discord
Mallow beeOP
i wan to map diffrent routes to different folders.
for eg, i want to keep my codebase in english but support routes in other language.

my folder is src > app > preroder
but i want the url https://myapp.de/vorbestellung
to route to it (vorbestellung is german word for preorder)

3 Replies

Acacia-ants
That can be configured via rewrite rules. Which is a good idea if you have 1-2 languages. If you have 10-20 languages it might be cumbersome to support. Example would be:
const nextConfig = {
async rewrites() {
return [
{
source: '/vorbestellung',
destination: 'preorders'
}
];
}
};
when placed inside next.config.*
Mallow beeOP
AHh thanks !
we will soon be having multiple language and deeper nesting, what would opyu recommend then ?
Acacia-ants
You are looking into deploying the different languages to different domains by the looks of it, so I would advice you to add all the rewrite rules as build arguments even tho it's gonna be hard to support. Maybe someone else can give a better advice idk. That's all i've got 😄