Short answer
Vercel applies a new or changed variable only to new deployments, so redeploy (a new build) after saving it. Check it’s enabled for the right environment, Production or Preview. And if the browser needs it, it must use your framework’s public prefix, such as NEXT_PUBLIC_ in Next.js, which also means it’s visible to anyone, so never put secrets there.
Why it’s undefined, and the fix
01
Saved, but not redeployed
“Any change you make to environment variables are not applied to previous deployments, they only apply to new deployments.” Vercel, Environment variables
Adding or editing a variable doesn’t change the deployment that’s already live. Redeploy, or push a commit, and check the new deployment.
02
Set for the wrong environment
“When selected, the Environment Variable will be applied to your next Production Deployment.” Vercel, Environment variables
Each variable is enabled for Production, Preview, Development or a mix. A variable set only for Preview is missing on your live domain, and the other way round. Branch-specific Preview values also override the general ones.
03
Needed in the browser without the public prefix
“Frameworks typically use a prefix to expose environment variables to the browser.” Vercel, Framework environment variables
Code that runs in the browser only sees variables named with your framework’s prefix, such as NEXT_PUBLIC_ in Next.js or VITE_ in Vite. Add the prefix only for values that are safe to publish, because the browser gets them.
Checked against the vendor’s docs on : Vercel docs: Environment variables; Vercel docs: Framework environment variables.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.See scope and start
Related: Vercel function timeout (504) · Build failed on Netlify or Vercel · Supabase service_role key exposed