QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.19k stars 52 forks source link

store locale outside of react context? #383

Open addlistener opened 3 months ago

addlistener commented 3 months ago

it could be useful in many ways if we want to access locale outside the react component

For example, providing a custom callback to sync with NEXT_LOCALE.

I know we can create a useEffect to achieve that. Is there a recommended way?

QuiiBz commented 3 months ago

The answer is different depending if you use the App Router or the Pages Router. Could you let me know which one you're using?

addlistener commented 3 months ago

I'm using pages router only.

I used to have both but later refactored app router to pages router because I couldn't make the official examples of server.ts & client.ts to work lol. Either one I import I get an error of cannot import in client/server. Not to mention mundane issues like https://github.com/QuiiBz/next-international/issues/379#issue-2199627303

But I guess it's app router not next-international. So I abandoned app router.