Environments
Vercel provides three default environments—Local, Preview, and Production:
- Local Development: developing and testing code changes on your local machine
- Preview: deploying for further testing, QA, or collaboration without impacting your live site
- Production: deploying the final changes to your user-facing site with the production domain
Pro and Enterprise teams can create Custom Environments for more specialized workflows (e.g., staging, QA). Every environment can define its own unique environment variables, like database connection information or API keys.
This environment is where you develop new features and fix bugs on your local machine. When building with frameworks, use the Vercel CLI to pull the environment variables for your project.
- Install the Vercel CLI:
npm i -g vercel
-
Link your Vercel project with your local directory:
vercel link -
Pull environment variables locally for use with application development:
vercel env pull
This will populate the .env.local file in your application directory.
Preview environments allow you to deploy and test changes in a live setting, without affecting your production site. By default, Vercel creates a preview deployment when you:
- Push a commit to a branch that is not your production branch (commonly
main) - Create a pull request (PR) on GitHub, GitLab, or Bitbucket
- Deploy using the CLI without the
--prodflag, for example justvercel
Each deployment gets an automatically generated URL, and you'll typically see links appear in your Git provider's PR comments or in the Vercel Dashboard.
There are two types of preview URLs:
- Branch-specific URL – Always points to the latest changes on that branch
- Commit-specific URL – Points to the exact deployment of that commit
Learn more about generated URLs.
The Production environment is the live, user-facing version of your site or application.
By default, pushing or merging changes into your production branch (commonly main) triggers a production deployment. You can also explicitly deploy to production via the CLI:
vercel --prodWhen a production deployment succeeds, Vercel updates your production domains to point to the new deployment, ensuring your users see the latest changes immediately. For advanced workflows, you can disable the auto-promotion of deployments and manually control promotion.
The first deployment of a new project is always a production deployment. This happens even when you:
- Import a Git repository in the dashboard
- Run
vercelorvercel deployfrom the CLI without--prod - Deploy from a branch that is not your production branch
Vercel does this so every new project has a production deployment and can receive production domains right away.
After that first production deployment, later deployments follow the usual rules:
- Commits to the production branch, or
vercel --prod, create production deployments - Other branches, pull requests, and
vercelwithout--prodcreate preview deployments
Custom environments are available on Enterprise and Pro plans
Custom environments are useful for longer-running pre-production environments like staging, QA, or any other specialized workflow you require.
Team owners and project admins can create, update, or remove custom environments.
- Go to your project's Environments settings in the Vercel Dashboard
- Click Create Environment
- Provide a name (e.g.,
staging), and optionally:- Branch Tracking to automatically deploy whenever a matching branch is pushed
- Attach a Domain to give a persistent URL to your environment
- Import variables from another environment to seed this environment with existing environment variables
To create an Authorization Bearer token, see the access token section of the API documentation.
curl --request POST \
--url https://api.vercel.com/v9/projects/<project-id-or-name>/custom-environments \
--header "Authorization: Bearer $VERCEL_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"slug": "<environment_name_slug>",
"description": "<environment_description>",
}'To create an Authorization Bearer token, see the access token section of the API documentation.
import { Vercel } from '@vercel/sdk';
const vercel = new Vercel({
bearerToken: '<YOUR_BEARER_TOKEN_HERE>',
});
async function run() {
const result = await vercel.environment.createCustomEnvironment({
idOrName: '<project-id-or-name>',
requestBody: {
slug: '<environment_name_slug>',
description: '<environment_description>',
},
});
// Handle the result
console.log(result);
}
run();You can deploy, pull, and manage environment variables to your custom environment with the CLI:
# Deploy to a custom environment named "staging":
vercel deploy --target=staging
# Pull environment variables from "staging":
vercel pull --environment=staging
# Add environment variables to "staging":
vercel env add MY_KEY stagingYou can scope Vercel Connect token access and trigger forwarding to a Custom Environment. This lets a staging or QA deployment use a connector without enabling it in any built-in Connect environment: Production, Preview, or Development.
In the Vercel Dashboard, open a connector's Projects section and select the Custom Environment when adding or editing a project link. From the CLI, pass the environment's slug:
vercel connect attach slack/acme-slack --environment stagingYou can also select the Custom Environment as a trigger destination in the dashboard or with the CLI:
vercel connect attach slack/acme-slack --environment staging --triggers \
--trigger-environment staging --trigger-path /api/slack-eventsThe trigger target is added to the connector's project link automatically. For a project with no existing trigger destinations, passing --environment staging, as shown above, keeps token access limited to staging. Existing trigger destinations remain registered, and the CLI preserves any Custom Environments they require on the project link. Before sending events to a Custom Environment, deploy to it and assign a domain to the environment. The domain must be verified and serve the environment's latest deployment directly rather than redirect elsewhere.
See Project links for token-access configuration and Triggers for destination setup and lifecycle behavior.
Each plan includes a number of custom environments per project at no additional cost. You can purchase more for any project in packs of five environments:
| Plan | Included per project | Additional environments | Maximum per project |
|---|---|---|---|
| Pro | 1 | $50 per month for each pack of five | 16 |
| Enterprise | 12 | $50 per month for each pack of five | 22 |
To purchase additional custom environments:
- Go to your project's Environments settings in the Vercel Dashboard
- In the Custom Environments section, use the stepper to set the number of environments for the project
- Click Save, then confirm the updated monthly cost
To stop the monthly charge, reduce the number back to your plan's included amount in the same section. If the project uses more environments than the reduced amount allows, delete custom environments first: reductions below current usage are not accepted.
Purchased packs apply to a single project. Members with permission to update the team's billing plan can change pack quantities.
Was this helpful?