Next.js Discord

Discord Forum

private env var undefined when logged

Answered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
in my .env.local i have 3 env vars.
first 2 are prefixed with: NEXT_PUBLIC_* which are working and logging fine.

the third is not meant to be public, so it's not prefixed with NEXT_PUBLIC_*. it has an arbitrary name.

when i try to log it, i get undefined. what am i doing wrong?

console.log(process.env.SUPABASE_SERVICE_ROLE_KEY)
Answered by joulev
you are running this console.log on the browser maybe. non-next_public env vars dont work there
View full answer

2 Replies