vercel env
The command is used to manage Environment Variables of a Project, providing functionality to list, add, remove, export, and run commands with environment variables.
To leverage environment variables in local tools (like or ) that want them in a file (like ), run . This will export your Project's environment variables to that file. After updating environment variables on Vercel (through the dashboard, , or ), you will have to run again to get the updated values.
To run a command with environment variables without writing them to a file, use . This fetches the environment variables directly from your linked Vercel project and passes them to the specified command.
Some frameworks make use of environment variables during local development through CLI commands like or . The sub-command will export development environment variables to a local file or a different file of your choice.
To override environment variable values temporarily, use:
If you are using vercel build or
vercel dev, you should use
vercel pull instead. Those commands
operate on a local copy of environment variables and Project settings that are
saved under .vercel/, which
vercel pull provides.
Using the vercel env command to list all Environment
Variables in a Vercel Project.
Using the vercel env command to add an Environment
Variable to a Vercel Project.
Using the vercel env command to remove an Environment
Variable from a Vercel Project.
Using the vercel env command to list Environment
Variables for a specific Environment in a Vercel Project.
Using the vercel env command to list Environment
Variables for a specific Environment and Git branch.
Using the vercel env command to add an Environment
Variable to all Environments to a Vercel Project.
Using the vercel env command to add an Environment
Variable for a specific Environment to a Vercel Project.
Using the vercel env command to add an Environment
Variable to a specific Git branch.
Using the vercel env command to add an Environment
Variable to a Vercel Project using a local file's content as the value.
Using the echo command to generate the value of the
Environment Variable and piping that value into the
vercel dev command. Warning: this will save the value
in bash history, so this is not recommend for secrets.
Using the vercel env command to add an Environment
Variable with Git branch to a Vercel Project using a local file's content as
the value.
Using the vercel env command to remove an Environment
Variable from a Vercel Project.
Using the vercel env command to download Development
Environment Variables from the cloud and write to a specific file.
Using the vercel env command to download Preview
Environment Variables from the cloud and write to the
.env.local file.
Using the vercel env command to download
"feature-branch" Environment Variables from the cloud and write to the
.env.local file.
The sub-command runs any command with environment variables from your linked Vercel project, without writing them to a file. This is useful when you want to avoid storing secrets on disk or need a quick way to test with production-like configuration.
Using vercel env run to run a command with
development Environment Variables from your Vercel Project.
Run the Next.js development server with development Environment Variables.
Run the development server with preview Environment Variables for a specific Git branch.
The -- separator is required to distinguish between
flags for vercel env run and the command you want to
run. Flags after -- are passed to your command.
The following options are available for :
- : Specify the environment to pull variables from. Defaults to . Accepts , , or .
- : Specify a Git branch to pull branch-specific Environment Variables.
These are options that only apply to the command.
The option can be used to bypass the confirmation prompt when overwriting an environment file or removing an environment variable.
Using the vercel env pull command with the
--yes option to overwrite an existing environment
file.
Using the vercel env rm command with the
--yes option to skip the remove confirmation.
The following global options can be passed when using the vercel env command:
For more information on global options and their usage, refer to the options section.
Was this helpful?