In Vite, this is powered by dotenv-expand . In Next.js, it also works out of the box.
In Next.js or Vite, this loading is automatic. .env.local.production
Environment variables are injected at for client-side code. If you modify your .env.local.production file, you must stop your local server, clear your build cache (like deleting the .next or dist folder), and run the build command again. Accidental Public Exposure In Vite, this is powered by dotenv-expand
vercel env add API_KEY production
A .env.local.production file is used to store for a production build that are intended to be kept local to a specific machine . In frameworks like Next.js or Create React App , this file overrides general production settings without being committed to version control, keeping sensitive keys secure on the server . Sample Content for .env.local.production Environment variables are injected at for client-side code
You log an API key, commit, and push. It's now in your Git history forever.