vercel env
Learn how to manage your environment variables in your Vercel Projects using the vercel env CLI command.The vercel env
command is used to manage Environment Variables of a Project, providing functionality to list, add, remove, and export.
To leverage environment variables in local tools (like next dev
or gatsby dev
) that want them in a file (like .env
), run vercel env pull <file>
. This will export your Project's environment variables to that file. After updating environment variables on Vercel (through the dashboard, vercel env add
, or vercel env rm
), you will have to run vercel env pull <file>
again to get the updated values.
Some frameworks make use of environment variables during local development through CLI commands like next dev
or gatsby dev
. The vercel env pull
sub-command will export development environment variables to a local .env
file or a different file of your choice.
vercel env pull [file]
To override environment variable values temporarily, use:
MY_ENV_VAR="temporary value" next dev
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.
vercel env ls
vercel env add
vercel env rm
vercel env ls [environment]
vercel env ls [environment] [gitbranch]
vercel env add [name]
vercel env add [name] [environment]
vercel env add [name] [environment] [gitbranch]
vercel env add [name] [environment] < [file]
echo [value] | vercel env add [name] [environment]
vercel env add [name] [environment] [gitbranch] < [file]
vercel env rm [name] [environment]
vercel env pull [file]
vercel env pull --environment=preview
vercel env pull --environment=preview --git-branch=feature-branch
These are options that only apply to the vercel env
command.
The --yes
option can be used to bypass the confirmation prompt when overwriting an environment file or removing an environment variable.
vercel env pull --yes
vercel env rm [name] --yes
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?