VERCEL ERRORS

Missing environment variable on Vercel

A variable that exists in your local .env file is undefined on Vercel until it is added to the project for the right environment and the app is redeployed.

What it means

Environment variables are key-value pairs configured outside your source code. Vercel applies each one to the environments you select: Production, Preview, Development or a custom environment. Your code reads them during the Build step or during function execution.

Any change to an environment variable is not applied to previous deployments. It only applies to new deployments.

How to fix it

  1. List every process.env value your code reads and compare it with the variables in the project settings.
  2. Add each missing variable under Environment Variables for every environment you deploy to. Production applies to the next Production deployment. Preview applies to deployments from branches other than the Production Branch.
  3. Redeploy. The new value is not applied to a deployment that already exists.
  4. To use the same values locally, run vercel env pull. It writes the Development variables to a .env file.
  5. In Next.js, a variable without the NEXT_PUBLIC_ prefix is only available on the server. A NEXT_PUBLIC_ variable is inlined into the JavaScript bundle at build time, so changing it requires a new build.

Limits to know

A deployment can use 64 KB of environment variables in total. Functions and Middleware that use the edge runtime are limited to 5 KB per variable.

What a DeployDoctor scan can check

The environment variable check reports process.env reads that are not documented in .env.example, secret-looking values exposed through NEXT_PUBLIC_, and an .env.example that .gitignore keeps out of the repository. A scan reads the repository only. It cannot see the values or names saved in your Vercel project settings.

Sources

Documentation last checked 2026-10-28. Vercel can change its documentation; confirm against the linked pages.