Vercel allows you to collaborate seamlessly with your team by providing Preview Deployments for every commit made to your project. In addition to this, you can provide Environment Variables specific to the Preview Environment, ensuring different variables are used for Preview and Production Deployments. Furthermore, it is possible to specify different Environment Variables for a specific Preview branch.
In some cases, it can be beneficial to use a staging environment to test your latest changes before pushing to Production. This article covers the steps required to set up a staging environment.
To create a staging environment, you'll first need to add a custom domain to your project.
You can add a domain by clicking the "Settings" tab from a Project and selecting the Domains section. From the Domains section, you can assign a domain to the appropriate Git branch.
Using the Environment Variables UI, which is available by selecting the Environment Variables tab in a Project's settings, we can add a Preview Environment Variable to the appropriate 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.
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.