Next.js Discord

Discord Forum

Migrating to the App router with i18n locale feature enabled

Unanswered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
I am building a localized application which I would like to incrementally migrate to use app router.

However, I am running into problems because I am using the i18n config from Next.js pages router and want to both localize "pages-router" pages, as well as "app-router" pages.
When having i18n config enabled and also having a middleware which redirects from root / to /:locale, I run into an infinite redirect loop.
You can reproduce it with the following repository: https://stackblitz.com/edit/stackblitz-starters-bdcejo?file=app%2F%5Blocale%5D%2Flayout.js

Unfortunately, Stackblitz seems to have some issues with the app router, so I recommend downloading the repository and executing it locally.

Is there any way of supporting both /app and /pages together with localization?

0 Replies