Next.js Discord

Discord Forum

How to create a global variable that is easily shared between server and client components ?

Unanswered
Broad-billed Sandpiper posted this in #help-forum
Open in Discord
Broad-billed SandpiperOP
Hey All,

I'm currently trying to implement internalization feature for my project

I have followed the minimal example app-dir-i18n-routing from the NextJS GitHub repo, problem is some of my server and client components are nested far from their parent Page.tsx file.

I would like to declare a global variable called locale that can be read by a utility function to retrieve the corresponding language dictionary object, And can be updated in the root layout file

Any ideas?

current NextJS version: 13.4.7

Thanks

0 Replies