What this thread does
The case
Your app builds and runs on your machine, but once deployed a setting such as an API address comes out undefined or empty. Success looks like: you know whether the value is read at build time or at run time, it has the prefix your framework needs, it is set in the right place and scope, and a missing one fails loudly before release.
This is a map, not new advice: each linked answer points to an existing WhatWorks thread. Nobody here ran this whole build; the Status column says what each linked thread rests on. "Tried" would need a linked trial report, and none of the linked threads has one yet.
Parts, in the order people do them
| Part | What to use | Status | Link |
|---|---|---|---|
| Vite | Client prefix, restart and build-time values | Documented: vendor or primary source, not tried (no linked trial) | Why is import.meta.env.MY_KEY undefined in my Vite app? |
| SvelteKit | Explicit variables or static versus dynamic imports | Documented: vendor or primary source, not tried (no linked trial) | SvelteKit env vars: which import do I use, and why is mine undefined? |
| Nuxt | Runtime config and public keys | Documented: vendor or primary source, not tried (no linked trial) | Why is my env variable undefined in the browser in Nuxt? |
| Host dashboard: Netlify or Render | Scopes, contexts and redeploy | Documented: vendor or primary source, not tried (no linked trial) | Env var is set on Netlify or Render but my app does not see it. Why? |
| Fail fast before release | Validate variables at build time | Documented: vendor or primary source, not tried (no linked trial) | How do I make my Next.js app fail fast when an env variable is missing? |
| Variables in Vercel project settings | No tested answer yet | No tested answer yet | none (see open request) |
Where it breaks
- The value shows in the browser as undefined: check the framework prefix in the thread for your framework.
- The value is set but the site still shows the old one: it was baked in at build time, redeploy as the host thread explains.
- The variable is set for the wrong environment or scope: see the Netlify and Render thread.
Open questions
- Vercel project environment settings and preview versus production scopes have no tested answer yet; ask for it with the request tool.
Status key
Documented means the linked thread cites official docs or a vendor source and was not run. Untried means the linked thread rests on a community post or on suggestions and was not run. Tried would need a linked trial report, and none exists yet.
Sources
- Linked WhatWorks threads above; each names its own primary sources.
Started from a post by @WhatWorks editors, packaged by the editor.