Environment Variables are accessible during both the Build Step and Runtime and can be configured for Production, Preview, and Development Environments individually.
This allows you to inject values that you don't want to place directly in your source code and change its behavior depending on the Environment its running in.
To declare an Environment Variable for your deployment, head to the Environment Variables page of your Project Settings.
You can add the following types of Environment Variables:
The Environment Variable value is stored as plain text and is visible to any user that has access to the Project. Plaintext Environment Variables should be used for non-sensitive information, such as
When selected, you will be prompted to create a new Secret or choose an existing one to populate the value of the Environment Variable. Secrets are encrypted and should be used for sensitive information like passwords or access tokens. Note that if you select Secret, you won't be able to assign the Variable to the Development Environment.
The value is automatically populated by the System when you create a Deployment. References to System Environment Variables can be used to provide your code with information about the System, such as the URL of the Deployment or the name of the Git branch deployed.
Once added, Environment Variables are applied to your subsequent deployments. They can then be consumed during the Build Step by the framework of your choice, or by a Serverless Function at Runtime.
The value of a Plaintext Environment Variable is stored as plain text and is visible to any user that has access to the Project.
To create a new Plaintext Environment Variable, select Plaintext in the first step.
Then, enter the Name of the Environment Variable. For example, if you are using Node.js and you create an Environment Variable named
API_URL, it will be available under
process.env.API_URL in your code.
Enter the desired Value for your Environment Variable and click Save.
Note that you can copy and paste a multi-line value.
Alternatively, you can insert a line break in the Value field by pressing
Enter key while holding
You can populate the value of an Environment Variable with a Secret. They are encrypted and provide a secure way to store and share sensitive information between Deployments.
To create a new Secret Environment Variable, select Secret in the first step.
Enter the desired Name for your Environment Variable.
In the Value field, you can search and select an existing Secret available in your Personal Account or Team.
Alternatively, you can also create a new Secret. Click on Create new Secret for… to do so.
Enter the Name and Value of the Secret. When you click Add, the Secret is created.
Lastly, select the desired Environments and click Save.
If you're looking to share a piece of information in Environment Variables across multiple Projects within the same Personal Account or Team on Vercel, Secrets are the best way to accomplish that.
Even if you only want to use the information inside a single Project, Secrets should always be used if you're dealing with sensitive information – like access tokens.
In order to delete them, you can use our command-line interface.
Vercel provides a set of Environment Variables that are automatically populated by the System, such as the URL of the Deployment or the name of the Git branch deployed.
To expose them to your Deployments, make sure Automatically expose System Environment Variables is checked in your Project Settings.
The following System Environment Variables will be exposed to your Deployments:
An indicator that the app is deployed and running on Vercel. Example:
The Environment that the app is deployed an running on. The value can be either
The URL of the deployment. Example:
The Git Provider the deployment is triggered from. Example:
The origin repository the deployment is triggered from. Example:
The account that owns the repository the deployment is triggered from. Example:
The ID of the repository the deployment is triggered from. Example:
The git branch of the commit the deployment was triggered by. Example:
The git SHA of the commit the deployment was triggered by. Example:
The message attached to the commit the deployment was triggered by. Example:
The username attached to the author of the commit that the project was deployed by. Example:
The name attached to the author of the commit that the project was deployed by. Example:
vercel devduring Development or if the Deployment is not triggered by a Git Commit.
In some cases, you might want to use the value of a System Environment Variable with a custom Environment Variable.
To add an Environment Variable referencing a System value to your Deployment, select Provided by System.
Enter the desired Name for your Environment Variable.
In the Value field, select the value that you want the System to provide for your Environment Variable when a Deployment is created.
For example, if you enter
GIT_SHA and select
GIT_SHA will be populated with the SHA of the commit that triggered the Deployment.
For each Environment Variable, you can select one or more Environments to apply the Variable to:
When selected, the Environment Variable will be applied to your next Production Deployment. To create a Production Deployment, push a commit to the Production Branch or run
The Environment Variable is applied to your next Preview Deployment. Preview Deployments are created when you push to a branch (for example,
The Environment Variable is for use when running your project locally, with
Environment Variables created for the Development Environment can be downloaded into a local development setup using the
vercel env pull command provided by Vercel CLI:
vercel env pull Downloading Development Environment Variables for project my-lovely-project ✅ Created .env file [510ms]
Running the command will create a
.env file in your project's directory, which can then be consumed by your framework's Development Command (like
If you're using
vercel dev, there's no need to run
vercel env pull, as
vercel dev automatically downloads the Development Environment Variables into memory.
vercel devor not.
For more information on the
vercel env command, check out this section.
Integrations can automatically add Environment Variables to your Project Settings. In that case, the Integration that added the Variable will be displayed: