How do I set up a staging environment on Vercel?

Information on how to set up a staging environment on Vercel.
Last updated on December 11, 2024
Environment Variables

Vercel provides the option for Pro and Enterprise users to set up a custom environment that can configured through the dashboard and be used as staging. To learn more, see Custom Environments.

With custom environments, you can use branch rules to automatically deploy your branch when the branch name matches the rule, attach a domain to your environment, set environment variables, or import environment variables from another environment.

For Hobby users, or others who can't use custom environments, it's also possible to set up a staging workflow by setting a branch-specific domain and environment variables for your preview deployment.

To create a staging branch:

  1. Go to your dashboard, and select your project. Then, select the Settings tab.
  2. In the Domains section, add a custom domain to your project and configure it as appropriate.
  3. Finally, follow the steps to assign it to a branch.
WARNING: When adding a domain, it is first automatically assigned to your default branch. Make sure to click the "Edit" button and assign it to the appropriate Git branch.
Adding a staging domain to the staging branch through a Project's Domain settings.
Adding a staging domain to the staging branch through a Project's Domain settings.
  1. Go to your dashboard, and select your project. Then, select the Settings tab.
  2. In the Environment Variables section, add your environment variables to your project and configure it to your Git branch.

Any branch-specific variables will override other variables with the same name. This means you don't need to replicate all your existing Preview variables for each branch – you only need to add the values you wish to override.

Adding an Environment Variable to the staging branch.
Adding an Environment Variable to the staging branch.

After adding all the necessary Environment Variables for your staging environment, make sure to redeploy your latest staging Preview Deployment to apply the Environment Variables.

Redeploying a Deployment from the Deployment overview.
Redeploying a Deployment from the Deployment overview.

Couldn't find the guide you need?