Environment Variables (CLI)
The vercel env command and the difference between vercel env pull and vercel pull.
The vercel env command manages a project's environment variables across the Production, Preview, and Development targets.
vercel env ls
Lists configured variables — names and targets, never the values.
vercel env ls
vercel env ls production # only a specific targetvercel env add
Adds a variable. You're prompted for the value and target if not supplied.
vercel env add API_KEY production
# Pipe a value from a file (avoids shell history exposure)
vercel env add API_KEY production < ./secret.txtYou can't combine
developmentwithproductionorpreviewin oneadd— add development variables in a separate command. If your team enforces sensitive-variable policy, development adds may be disallowed and production/preview writes treated as sensitive.
vercel env rm
vercel env rm API_KEY productionvercel env pull
Exports development variables to a local file (default .env.local) for framework dev servers like next dev or vite.
vercel env pull
vercel env pull .env.local
vercel env pull --environment=preview .env.previewvercel env pull vs vercel pull
This is the common point of confusion:
| Command | Writes to | Use when you run |
|---|---|---|
vercel env pull | a .env file | your framework's dev server (next dev, vite, …) |
vercel pull | the .vercel/ directory | vercel dev or vercel build |
vercel dev and vercel build read project settings and variables from .vercel/, which vercel pull provides. Framework dev commands read .env files, which vercel env pull provides.
Running a command with the variables
vercel env pull .env.local
# then start your dev server, which reads .env.local
npm run dev