how to implement it?
Let’s look at a few approaches

handling routing ourselves

we can create a catch all route, and do routing from that file. so basically we disregard nextJS /app router and /pages router.

This will work, but it’s kinda stupid because we kinda reinvent the wheel. There’s an existing way of routing yet we disregard those.

Let’s try not to do this. any other way?

use nextJS internationalization

NextJS has two way of routing,
/app and /pages.

/pages has a really good internationalization support!

check this
not much to explain. it’s quite good.

/app router basically has no i18n support

after looking at nextJS internationalization documentation for /app router, basically you handle those stuff yourself using other nextJS feature. there’s no additional feature.

depending on how you handle internationalization, /app router might be a deal breaker.

“can you explain more? what do you mean as depending on how you handle internationalization?”


based on documentation in /pages there are two dominant to handle internationalization, to be precise, way of storing the locale information.
first, in the domain - example.en/about
second, in the path - example.com/en/about

usually there are default locale. let’s say en

if you use the second approach, sometimes you want to remove the lang information from the path - from example.com/en/about to example.com/about
this is the exact configuration that is not handled by nextJS /app router. you might have to resort to the default approach, that is handling routing yourself.


then how?

source: stackoverflow

we can take advatage other nextJS feature. check nextJS rewrite

it’s like redirection, but without changing the URL

this might become an issue tho