Access global data
Unanswered
Masai Lion posted this in #help-forum
Masai LionOP
I need to access server configuration data like the region the server is running into. How to do it in next.js?
I would like to access this data in client and server components seamlessly. Ideally there should be a way to:
- if server, just get the data (e.g. from an environment variable)
- if client, get the data from the server but without a further Fetch call. Another fetch seems unnecessary to me, because the data could have been pushed to the client on first rendering.
I can't prefix my environment variable with NEXTPUBLIC because from my understanding they are set at build time, and I need them to be dynamic.
I would like to access this data in client and server components seamlessly. Ideally there should be a way to:
- if server, just get the data (e.g. from an environment variable)
- if client, get the data from the server but without a further Fetch call. Another fetch seems unnecessary to me, because the data could have been pushed to the client on first rendering.
I can't prefix my environment variable with NEXTPUBLIC because from my understanding they are set at build time, and I need them to be dynamic.