Library / Terminal & command line / Environment variable
No. 105·noun·also called env var, .env, .env file

Environment variable

A named setting stored outside the code, like an API key, that the app reads when it runs.

SPECIMEN · DIAGRAM · FLOW
DataSTRIPE_KEYset on the platform
AppYour codereads the name
ServiceStripe
injected at run timeuses the key
Definition

What it is

An environment variable is a name and a value (STRIPE_KEY=sk_test_...) set on the machine or platform rather than written into the code. The app reads it when it starts.

They exist for two reasons. Secrets like API keys stay out of the code, so they don't leak when code is shared. And the same code can behave differently per environment: test keys in development, live keys in production.

Locally they often live in a .env file, which should never be committed to version control. On hosting platforms they're set in a dashboard, usually under "Secrets" or "Environment."

Say it like a builder

How to ask for it

Vague

“Here's my Stripe key, put it in the code.”

Precise

“Store my Stripe secret key as an environment variable called STRIPE_SECRET_KEY, with the test key in development and the live key in production. Never hardcode it or log it.”

Why it works

Asking for an environment variable keeps the secret out of your code and lets each environment use the right key.

In the wild

You've seen this in

  • PA .env file in a project folder
  • V"Environment variables" settings in Vercel or Netlify
  • F"Missing STRIPE_SECRET_KEY" errors on first run
Usage note

Often confused with