Separation of Code base, based on Regions
Unanswered
Egyptian Mau posted this in #help-forum
Egyptian MauOP
Hello,
I wanted to know that, I've a Nextjs App (Page Router), now we're expanding it to other region like currently we're in India, and now we'll expand it to UAE region, so I wanted to know that is there any way to make 2 separate modules in Nextjs whereas 1 Module will be for India Region & 2nd Module for UAE Region, something this way is possible in Nextjs Page Router?
I wanted to know that, I've a Nextjs App (Page Router), now we're expanding it to other region like currently we're in India, and now we'll expand it to UAE region, so I wanted to know that is there any way to make 2 separate modules in Nextjs whereas 1 Module will be for India Region & 2nd Module for UAE Region, something this way is possible in Nextjs Page Router?
25 Replies
Shy Albatross
what do you mean by "separate modules"?
@Shy Albatross what do you mean by "separate modules"?
Egyptian MauOP
like same code base but for 2 different regions
Asian paper wasp
You mean languages and regions?
/en
/in
/ru
/en
/in
/ru
Egyptian MauOP
I guess, yes
like for
like for
/en it'll have some different components, for /in it'll be differentShy Albatross
well then it's just a route segment /pages/[region]/...
Egyptian MauOP
pages/[region]/* this way, so how I can identify the region automatically?Shy Albatross
it's a route segment, you read it through params on your page
basics of next routing
Asian paper wasp
If you are going to use different components, then do like Atom says.
If you want the same components but translated, then you'll need to setup locates for Next, and probably react-i18n.
If you want the same components but translated, then you'll need to setup locates for Next, and probably react-i18n.
@Shy Albatross it's a route segment, you read it through params on your page
Egyptian MauOP
so I need to pass it manually?
@Asian paper wasp https://nextjs.org/docs/pages/building-your-application/routing/internationalization
Egyptian MauOP
I saw the docs, but unable to identify that how does it'll automatically detect the locale? like when I hit
example.com from Indian region then it should take me to Website related to India, and when I open in UAE region then example.com/ae how it can be done?@Asian paper wasp https://nextjs.org/docs/pages/building-your-application/routing/internationalization#automatic-locale-detection
Egyptian MauOP
so with this, I don't need to setup something like
/pages/[region]/* ?@Asian paper wasp https://nextjs.org/docs/pages/building-your-application/routing/internationalization#automatic-locale-detection
Egyptian MauOP
and I need it as like
domain.com/in & domain.com/aeAsian paper wasp
They are 2 separate things. If you are not using translations on the same page (i.e. react-i18n or next-i18n) then you will need to setup the page router manually.
@Asian paper wasp They are 2 separate things. If you are not using translations on the same page (i.e. react-i18n or next-i18n) then you will need to setup the page router manually.
Egyptian MauOP
is there any docs or tutorial for this?
Asian paper wasp
Look up each package. They have their own docs.
Egyptian MauOP
so you suggest to use either package to achieve the above functionality?
Asian paper wasp
Never known anyone to use a completely different page for a different language. Most people just translate the page.
So use any of the packages that Next recommends in their docs to do this.
So use any of the packages that Next recommends in their docs to do this.
Egyptian MauOP
I don't want to translate the page, but the website components, forms and other stuffs will vary from region to region, like for India Region & for UAE Region many things will differ
Asian paper wasp
I know.
@Asian paper wasp I know.
Egyptian MauOP
so you're suggesting to use the recommended package to achieve this?
Great Knot
You need to get location of user and then return ‘region’ or default ‘region’ into route when you load your web.
@Great Knot You need to get location of user and then return ‘region’ or default ‘region’ into route when you load your web.
Egyptian MauOP
how it can be possible?