web dev//environment variable

An environment variable is a named value set in the environment of the process that runs the code instead of in its source files, and it is used to give the same code different settings and secrets in each place it runs. In Node.js it is read through `process.env.NAME`.


An environment variable is a named value set in the environment of the process that runs the code instead of in its source files, and it is used to give the same code different settings and secrets in each place it runs. In Node.js it is read through process.env.NAME.

In local development the variables are read from .env.local, which Next.js and Vite load automatically on startup. In production (Vercel, Cloudflare Pages) they are configured in the platform dashboard, with the same names and different values.

They are what tells one codebase which deployment environment it is in: the same variable names hold the development database in preview and the real one in production.

They are where API keys live. The Supabase URL, the anon key, the service role key and the Google Client Secret all go in .env.local, which is in .gitignore and never committed.

The NEXT_PUBLIC_ prefix makes a variable available in the frontend bundle, and without it the variable is server-only. That is how the publishable key reaches the browser while the secret key stays on the server.