Vercel CLI Cheat Sheet: Deploy, Env, Logs and vercel.json Routing
Checked against Vercel CLI Vercel CLI 68.0.0 (npm, 27 Nov 2026); docs read 28 Nov 2026 on 28 November 2026. Each section links to the official docs it was checked against.
This sheet covers the Vercel CLI commands you use around a deploy and the vercel.json keys that control routing, headers and functions. It was checked against vercel.com/docs on 28 November 2026, when the latest CLI on npm was 68.0.0. The CLI isn't installed here, so rows are marked as checked in the docs only.
When to use what
If your repo is connected to Git, pushes already create deployments and you mostly need the CLI for three things: vercel link once per checkout, vercel env pull to get variables onto your machine, and vercel logs or vercel inspect when something breaks. Plain vercel creates a preview; add --prod only when you mean it.
For CI outside Vercel's own Git integration, authenticate with the VERCEL_TOKEN environment variable rather than --token. The docs prefer the variable because command-line arguments can show up in process lists and logs. When a production deploy goes bad, vercel rollback is faster than reverting a commit and waiting for a build; vercel promote is the opposite move, making an existing preview the current production deployment.
In vercel.json, reach for redirects when the visitor should see the new URL, and rewrites when the URL should stay the same but the content comes from elsewhere. Redirects are permanent (308) unless you say permanent: false (307) or set a statusCode. Only one config file is allowed per project, and you can now write it as vercel.json, vercel.toml or vercel.ts. The Vercel MCP server exposes some of this to AI assistants, and if you're building AI features on the platform, see our page on the Vercel AI SDK.
vercelDeploy the current directory as a preview (deploy is the default command)
vercel deploy --prodDeploy straight to production
vercel build --prodBuild locally or in your own CI using production settings
vercel promote <deployment-url>Make an existing deployment the current production one
vercel rollbackRoll production back to a previous deployment
vercel redeploy <deployment-url>Rebuild and redeploy an existing deployment
vercel listList recent deployments for the linked project
In CI, set VERCEL_TOKEN instead of passing --token. If both are present, --token wins.
vercel linkConnect this local folder to a Vercel project
vercel env listShow the project's environment variables
vercel env add DATABASE_URL --environment productionAdd a variable to one environment; the CLI asks for the value
vercel env pull .env.localDownload development variables into a local file
vercel env run -- npm run devRun a command with the project's variables injected
vercel pull --environment=productionFetch project settings and production variables for a local vercel build
vercel logsQuery runtime logs for the linked project
vercel logs --deployment <deployment-url>Limit logs to one deployment
vercel inspect <deployment-url> --logsShow a deployment's details together with its build logs
vercel inspect <deployment-url> --waitWait for a deployment to finish, handy in CI scripts
vercel dev --listen 3000Run the project locally in a Vercel-like environment on port 3000
vercel whoamiPrint which account the CLI is logged in as
Add "$schema": "https://openapi.vercel.sh/vercel.json" at the top for editor autocomplete. If cleanUrls is true, leave .html off rewrite sources and destinations.
{ "source": "/about", "destination": "/about-our-company.html" }Rewrite: serve another file while the URL in the browser stays /about
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]Send every path to index.html for a single-page app
{ "source": "/blog/:path*", "destination": "/news/:path*" }Redirect a whole section, keeping the rest of the path (308 by default)
{ "source": "/me", "destination": "/profile.html", "permanent": false }Temporary redirect with status 307
{ "source": "/user", "destination": "/api/user", "statusCode": 301 }Redirect with an exact status code; can't be combined with permanent
"headers": [{ "source": "/:path*", "headers": [{ "key": "X-Frame-Options", "value": "DENY" }] }]Add a response header to every path
"cleanUrls": trueDrop .html from URLs; requests with the extension get a 308 to the clean path
"trailingSlash": false308-redirect /about/ to /about; true does the reverse
"functions": { "api/report.js": { "maxDuration": 30 } }Let one function run up to 30 seconds, within your plan's limit
"crons": [{ "path": "/api/cron", "schedule": "0 10 * * *" }]Call a path on a schedule (schedule string up to 256 characters)
vercel crons add --path /api/cron --schedule "0 10 * * *"Add the same cron entry from the CLI (beta command)
Worked example: Move a blog section and check the redirect before production
You're renaming /blog/* to /news/* and want old links to keep working.
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"redirects": [
{ "source": "/blog/:path*", "destination": "/news/:path*" }
]
}
vercel # preview deployment, prints a URL
curl -sI https://<preview-url>/blog/hello | head -3
vercel deploy --prod
The preview gives you a throwaway URL to test against. In the curl -sI response, look for a 308 status and a location header ending in /news/hello; 308 is what Vercel uses when permanent is left out, which is what you want for a move search engines should remember. If you see 307, someone set permanent: false. Only after that check do you deploy with --prod. I didn't run this against a real project, so there's no captured output here.
Common mistakes
Passing
--token $VERCEL_TOKENon the command line in CI.Export
VERCEL_TOKENas a secret environment variable instead; arguments can leak into logs and process lists.Using a rewrite when you wanted the visitor's URL to change, then wondering why the address bar still shows the old path.
Rewrites keep the URL; redirects change it. Use
redirectsfor moved pages.Setting both
permanentandstatusCodeon one redirect.The docs say
statusCodecan't be combined withpermanent. Pick one.Adding a
vercel.tsnext to an existingvercel.jsonand expecting both to apply.Only one config file is allowed per project. Move everything into the file you keep.
Forgetting
vercel linkin a fresh clone and getting prompts or the wrong project.Run
vercel linkonce per checkout, thenvercel env pullto fill in local variables.
Related cheat sheets
Sources
- https://vercel.com/docs/cli
- https://vercel.com/docs/project-configuration
- https://vercel.com/docs/project-configuration/vercel-json
- https://vercel.com/docs/cli/release-notes
- https://registry.npmjs.org/vercel/latest
How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.