How to add translated routes (translating the route paths) in a NextJS app?


This Content is from Stack Overflow. Question asked by cbdeveloper

I’m creating a NextJS web-app that will be deployed in multiple countries. But it’ll be deployed separately. I’ll change only the variables on each deploy.

The issue is that I have some routes with meaningful slugs that need to be translated for the language of the country.


de: '/route-path-in-de',
es: '/route-path-in-es',
fr: '/route-path-in-fr',

Since NextJS uses a file/folder based routing system. What is the best way for me to achieve this? Will I need to create a file per translation, like?


Is that the only way?


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?