Cloud and deployment · Intermediate · 16 min
Promote, protect and roll back deployments on Vercel
By Padding · Updated 18 Nov 2026
Vercel CLI 67.0.0 · Vercel (web) · November 2026
You will stage production builds on Vercel instead of letting every push to main go live, promote a tested build with vercel promote, roll back with vercel rollback, keep previews behind Vercel Authentication and give each environment its own variables.
On this page
Once a project is on Vercel, every push to main goes straight to your production domain. That is fine for a personal site. For anything people rely on, you want a gap between "the build passed" and "visitors see it", a fast way back when a release goes wrong, and previews that strangers cannot browse.
This tutorial picks up where /tutorials/deploy-a-next-js-app-to-vercel stops. You will change the project so that pushes to main build a staged production deployment that waits for you, promote it from the command line once you have checked it, roll back to the previous release in seconds, and learn what a rollback leaves untouched. Along the way you lock previews behind Vercel Authentication and give each environment its own variables, so a preview never talks to your production database.
All commands run on your computer, in the linked project folder, with Vercel CLI 67. Install that exact version and confirm you are signed in:
npm install --global vercel@67.0.0
vercel --version
vercel whoamivercel --version prints 67.0.0 (sometimes with a line naming the CLI first), and vercel whoami prints your username. If it asks you to log in, run vercel login.
Step 1 · See how branches map to environments
Vercel has three built-in environments, and every deployment belongs to one of them:
- Development is your own machine. It only matters for variables you pull with
vercel env pull. - Preview is every deployment from a branch other than your production branch, every pull request, and every
vercelrun without--prod. - Production is every deployment from the production branch (usually
main) and everyvercel --prodrun. The first deployment of a new project is always production, whatever branch it came from.
Pro and Enterprise teams can add custom environments, such as staging, each with its own branch tracking, domain and variables. In November 2026 Pro includes one per project and Enterprise twelve. On Hobby, a long-lived staging branch with its own domain and preview variables does the same job.
Each deployment keeps its own URL forever (until your retention settings delete it), with its build and its copy of the environment variables baked in. Your production domain is only a pointer to one of those deployments. Promoting and rolling back both move that pointer, and that is why both can be fast.
List the production deployments of your project:
vercel list --environment productionCheck it worked
The table shows one row per production deployment, newest first, with its age, URL, status and duration. At least one row has the status Ready. Open the newest URL in your browser and compare it with your production domain: they show the same page, because the domain points at that deployment. Copy that URL into a note as GOOD_URL; you will roll back to it later.
Step 2 · Stage production builds instead of shipping them
Turn off the automatic move of the production domain, so that a push to main still builds with production settings but does not go live:
- Open the project in the Vercel dashboard and go to Settings, then Environments.
- Select Production and find the Branch Tracking section.
- Turn off Auto-assign Custom Production Domains and save.
From now on, every push to main creates a staged production deployment. It is built with your Production environment variables and has its own URL, but your domain keeps serving the current release until you promote the new one. This is not a preview: it uses production configuration, so it can read and write your production data. Keep that in mind when you test it.
Make a small, visible change and push it. Use a new file, so the step works whatever your starter looks like:
mkdir -p app/release
printf 'export default function Page() {\n return <h1>Release 2</h1>\n}\n' > app/release/page.tsx
git add app/release/page.tsx
git commit -m "Add release page"
git pushIf your app lives in src/app, create the file in src/app/release/ instead.
To stage a build from the command line instead of Git, run vercel --prod --skip-domain in the project folder. It creates the same kind of staged production deployment and prints its URL.
Check it worked
Wait for the build, then run vercel list --environment production again. The newest row is your release, with status Ready. Open your production domain followed by /release: it returns a 404, because the domain still points at the old deployment. Open the newest deployment's URL followed by /release: it shows Release 2. In the dashboard, the deployment is labelled as staged rather than current.
Step 3 · Test the staged build, then promote it
Check the staged deployment the way your users will meet it. Open its URL on a phone as well as a laptop: a slow mid-range Android phone on mobile data is a fairer test of a release than a fast office connection, and for many of your visitors in Nigeria and across Africa it is the normal way they will see the site. If you need to call an API route from a script and the deployment is protected (you set that up in the next step), vercel curl adds the protection bypass header for you:
vercel curl /release --deployment <staged-deployment-url>Replace <staged-deployment-url> with the URL from vercel list. When you are happy, promote it:
vercel promote <staged-deployment-url>Promoting a staged production deployment does not rebuild anything. Vercel moves your production domains to the deployment you named, usually within seconds. The command waits up to three minutes for that to finish; --timeout changes the wait but not the promotion itself, and vercel promote status shows a promotion that is still in progress.
Two cases behave differently:
- Promoting a preview deployment. The CLI asks you to confirm, then rebuilds the code as a new production deployment with your Production variables. The preview's own variables are never used in production. The command prints the new deployment's link and exits without waiting; pass that link to
vercel inspect --waitto follow the build. - A deployment that was promoted before. You cannot promote it a second time. To go back to it, roll back instead.
Check it worked
Open your production domain followed by /release. It now shows Release 2. In the dashboard, open Deployments: the deployment you promoted is marked Current. Copy its URL into your note as NEW_URL.
Step 4 · Keep previews behind Vercel Authentication
Preview URLs are guessable enough to be shared by accident, and they often run code that is not finished. Vercel Authentication sends anyone who opens a protected URL to a Vercel login, and only lets in people with access to the project. It is available on every plan, and new projects usually start with it turned on, so check rather than assume:
- In the project, go to Settings, then Deployment Protection.
- In the Vercel Authentication section, make sure the toggle is on.
- Choose Standard Protection as the scope and save. It protects every deployment URL, previews and staged builds included, but leaves your production domains public.
All Deployments protects your production domain too, which suits an internal tool. Password Protection and Trusted IPs are other methods, but they are paid or Enterprise features, so check your plan before you plan around them.
To let someone outside your team see one preview, you have two choices:
- They open the URL, sign in with their own Vercel account and request access. You approve it under Deployment Protection, in Requests. A Hobby account can grant access to only one external user, so on Hobby this suits a single reviewer.
- You create a Shareable Link from the deployment's share menu. Anyone with the link can open that deployment, so send it privately and revoke it when the review is over.
For test runners and CI jobs, create a Protection Bypass for Automation secret on the same settings page. Store it as a secret in your CI system, never in the repository, and send it in the x-vercel-protection-bypass header. vercel curl does this for you from your own machine.
Check it worked
Open a private (incognito) browser window, where you are not signed in to Vercel. Paste the URL of any preview or staged deployment: you see a Vercel login page instead of your site. Then open your production domain in the same window: your site loads, because Standard Protection leaves production public.
Step 5 · Give each environment its own variables
A preview that uses your production API key or database is a production release with extra steps. Give every environment its own values. Set the production value, then a separate preview value for the same name:
vercel env add DATABASE_URL --environment production --type secret
vercel env add DATABASE_URL --environment preview --type secretEach command prompts for the value, so it stays out of your shell history. --type secret stores the variable as Secret, which means nobody can read the value back in the dashboard (it is also the default for Production and Preview, but without a type flag the CLI stops to ask Environment Variable type?). Keep a copy in your password manager.
A long-lived branch can override a preview value. Only preview variables can target a branch. For a staging branch on Hobby:
vercel env add DATABASE_URL --environment preview --git-branch staging --type secretOn Pro, with a custom environment named staging, target it by name instead, and deploy to it with vercel deploy --environment=staging:
vercel env add DATABASE_URL --environment staging --type secretVariables are read when a deployment is built. Changing a value does nothing to deployments that already exist, so redeploy (or push a commit) after a change. Remember that staged production builds always get the production values: test risky data changes against a preview or staging environment, not a staged build.
Check it worked
Run vercel env list --environment production and vercel env list --environment preview. DATABASE_URL appears in both lists, and the values are hidden. If you added the branch override, vercel env list --environment preview --git-branch staging lists it for that branch. Remove any variable you added only to practise with vercel env remove <name> --environment <environment>.
Step 6 · Roll back a bad release
Suppose Release 2 breaks checkout. Roll back to the release before it:
vercel rollback <GOOD_URL>Replace <GOOD_URL> with the URL you noted in the first step. Like a staged promotion, this does not rebuild: Vercel points your production domains back at a deployment that already exists, so it takes seconds. vercel rollback status shows a rollback in progress, and only one rollback or promotion runs per project at a time. In the dashboard, the same action is Instant Rollback on the production deployment tile.
Which deployments you can roll back to depends on your plan. Only deployments that once served production are eligible. On Hobby you can go back one release, to the previous production deployment; naming an older one fails with To rollback further than the previous production deployment, upgrade to pro. Pro and Enterprise can pick any eligible deployment.
Know what a rollback does not change before you rely on it:
- Environment variables. The old deployment runs with the values it was built with. If you rotated a leaked key since then, the rollback brings the old key back into use. Revoke leaked keys at the provider so that an old deployment cannot use them.
- Cron jobs. The cron job definitions of the old deployment come back with it, including its copy of
CRON_SECRET. If you turned on Disable Cron Jobs for the project, that setting stays as it is. - Your data. Database migrations, files in storage and calls to outside services are not undone. If
Release 2changed your database schema, the old code may not work with the new schema. Plan migrations so the previous release can still run.
After a rollback, Vercel turns off auto-assignment of production domains, so new pushes to main do not replace the deployment you rolled back to. With the staging setup from earlier, that was already the case. It stays off only until you undo the rollback by promoting a deployment, which turns auto-assignment back on; the next step shows how to switch it off again.
Check it worked
Open your production domain followed by /release. It returns a 404 again, because the domain now points at the older deployment. The dashboard's production tile shows the project as rolled back, with a Manage button.
Step 7 · Fix forward and leave the rolled-back state
A rollback buys time; it is not the fix. Commit the fix to main and push it. Because auto-assignment is off, the push builds a new staged production deployment. Test it the way you did before, then promote it:
vercel promote <fixed-deployment-url>Promoting ends the rolled-back state, and it also turns auto-assignment of production domains back on. From that moment, every push to main goes live straight away again, so the staging setup from earlier is gone. To keep staged releases, go to Settings, Environments, Production, Branch Tracking and turn Auto-assign Custom Production Domains off again. Then keep the habit: push, check the staged build on a real phone, promote.
Write the URL of each release you promote into your release notes or pull request. When something breaks at night, the URL to roll back to is then one search away, and you can run vercel rollback from a laptop on a mobile hotspot without loading the dashboard.
Check it worked
Your production domain followed by /release shows the fixed page, and the production tile no longer shows the rolled-back state or the Manage button. vercel list --environment production lists your fixed deployment as the newest one, with status Ready. Under Settings, Environments, Production, Branch Tracking, Auto-assign Custom Production Domains is off. To prove it, push a trivial commit (a comment change) and wait for the build: your production domain still serves the fixed deployment, and the dashboard marks the new one as staged, not Current.
Next steps
- Go back over the first deploy, domains and clean-up:
/tutorials/deploy-a-next-js-app-to-vercel. - Keep the bypass secret and API keys out of your repository:
/tutorials/keep-secrets-out-of-git. - Point your own domain at the project before you rely on promotion:
/tutorials/dns-records-explained-a-cname-mx-txt.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials