I have an .env.local with a key
NEXT__API__KEY=abcd
when I call this in the components, in my terminal show the answer in a console.log(process.env.NEXT__API__KEY);
// abcd
but in the client on the browser, show me undefined.
Please, how do I solve this?
CodePudding user response:
Replace your API key name with :
NEXT_PUBLIC_ API__KEY
That is how you expose your env variables to client side.
PS: You probably do not want your API Keys in client.