What is going on
Environment variables are undefined in your deployed application even though they're set in the platform. API keys, database URLs, and other config values come back as undefined.
Variables work fine locally but disappear after deployment.
Error messages you might see
Common causes
- Using process.env.VAR instead of NEXT_PUBLIC_VAR for client-side access
- Environment variables set after build completes
- Wrong environment selected in deployment platform (staging vs production)
- Variable name mismatch between code and platform settings
- Quotes or special characters in env var value causing parsing issues
How to fix it
For client-side vars: prefix with NEXT_PUBLIC_ (e.g., NEXT_PUBLIC_API_URL)
For server-side only: use plain process.env.PRIVATE_VAR (won't leak to browser)
Set env vars BEFORE triggering redeploy in your platform
Test locally: create .env.local with same vars and run npm run build
Getting help takes about a minute
No hiring, no back and forth. A real person looks at your app.
-
1
Describe it
Tell us what you need in plain words. You don't have to be technical or have an account to start.
-
2
Free 15-minute call
A verified developer calls you. Many tasks are sorted right there, and it costs nothing.
-
3
Pay after you approve
If there is more to do, you get one fixed price up front. You pay only once you are happy.
Real people, reviewed by hand
Developers who do this every day
Every developer is approved by our team before they can take a task. Describe yours and the first one who is free picks it up.
Get helpQuestions
What's the difference between .env and .env.local?
.env is version controlled, .env.local is git-ignored. Use .env.local for secrets locally
How do I set env vars in Vercel?
Settings > Environment Variables. Make sure you set them before deploying
Should secrets use NEXT_PUBLIC_?
NO! Use NEXT_PUBLIC_ only for public values. Secrets stay as plain process.env.VAR and are only available on server