Domain based i18n in App Router
Unanswered
Mountain Quail posted this in #help-forum
Mountain QuailOP
We have about 9 different domains and currently using the
i18n: domains [] setting in next.config.js. And render different content (mainly translations) based on the domain requested. Currently i don't see any possibility/docs to migrate that to apps router. Any idea how to do this?12 Replies
@Mountain Quail We have about 9 different domains and currently using the `i18n: domains []` setting in next.config.js. And render different content (mainly translations) based on the domain requested. Currently i don't see any possibility/docs to migrate that to apps router. Any idea how to do this?
maybe try this
* add /[lang]/your page etc
* deploy that to some-subdomain.yourapp.com
* rewrite [lang].yourapp.com to some-subdomain.yourapp.com/[lang]
* add /[lang]/your page etc
* deploy that to some-subdomain.yourapp.com
* rewrite [lang].yourapp.com to some-subdomain.yourapp.com/[lang]
Mountain QuailOP
Rewrite in Middleware or next config?
@Mountain Quail Rewrite in Middleware or next config?
could be middleware, could be next config, you choose
i myself haven't deployed a multi-tenant app before so idk about how smoothly middleware and next config work with multi tenancy
Mountain QuailOP
Ok thanks! I'll try
vercel has an almost identical example of this using the Vercel Domains API here : https://github.com/vercel/platforms
There is a
The difference is that you are using i18n subdomain instead of custom domains, but it can help to grok out it can work out
There is a
[domain] route and a middleware that rewrites subdomain to that routeThe difference is that you are using i18n subdomain instead of custom domains, but it can help to grok out it can work out
Asian black bear
Hi @joulev
I am in the same situation with @Mountain Quail
But I exactly need domain routing not sub-path routing.
Does app router support this in any chance?
I am in the same situation with @Mountain Quail
But I exactly need domain routing not sub-path routing.
Does app router support this in any chance?
@Asian black bear Hi <@484037068239142956>
I am in the same situation with <@152139919542845440>
But I exactly need domain routing not sub-path routing.
Does app router support this in any chance?
if you don't want to do rewrites* then you have to deploy separate apps in separate domains
* note that browsers do not detect rewrites. if you rewrite from A to B, users going to A will be shown the content of B as if no rewrites happen
* note that browsers do not detect rewrites. if you rewrite from A to B, users going to A will be shown the content of B as if no rewrites happen
many, if not most if not all of, multi-tenant apps work on the basis of rewrites to subpaths. if you don't like that you have to deploy separately
@joulev many, if not most if not all of, multi-tenant apps work on the basis of rewrites to subpaths. if you don't like that you have to deploy separately
Asian black bear
But we did it with page router.
We had i18n config on next.config.js and then, you know - we got locale value from useRouter of next/router.
We had i18n config on next.config.js and then, you know - we got locale value from useRouter of next/router.
^^ this is my help post