Next.js Discord

Discord Forum

process.env NEXT_PUBLIC_ env variables undefined in browser

Answered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
Expected behavior: After adding NEXT_PUBLIC_ environment variables to the .env.local and starting next with npx next start, the NEXT_PUBLIC_ environment variables should be available in the browser.
Result: process.env is undefined (and none of the variables are available).

Environment details:
Next 14.0.4
Node 20.18.0

How do I resolve this?
Answered by Asian black bear
You need to next build before you next start.
View full answer

1 Reply

Asian black bear
You need to next build before you next start.
Answer