Skip to content

Menu

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.

vercel

Deploy the current directory as a preview (deploy is the default command)

From the docs, not run by us
vercel deploy --prod

Deploy straight to production

From the docs, not run by us
vercel build --prod

Build locally or in your own CI using production settings

From the docs, not run by us
vercel promote <deployment-url>

Make an existing deployment the current production one

From the docs, not run by us
vercel rollback

Roll production back to a previous deployment

From the docs, not run by us
vercel redeploy <deployment-url>

Rebuild and redeploy an existing deployment

From the docs, not run by us
vercel list

List recent deployments for the linked project

From the docs, not run by us
vercel logs

Query runtime logs for the linked project

Try it: Log ParserFrom the docs, not run by us
vercel logs --deployment <deployment-url>

Limit logs to one deployment

From the docs, not run by us
vercel inspect <deployment-url> --logs

Show a deployment's details together with its build logs

From the docs, not run by us
vercel inspect <deployment-url> --wait

Wait for a deployment to finish, handy in CI scripts

From the docs, not run by us
vercel dev --listen 3000

Run the project locally in a Vercel-like environment on port 3000

From the docs, not run by us
vercel whoami

Print which account the CLI is logged in as

From the docs, not run by us

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

From the docs, not run by us
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]

Send every path to index.html for a single-page app

From the docs, not run by us
{ "source": "/blog/:path*", "destination": "/news/:path*" }

Redirect a whole section, keeping the rest of the path (308 by default)

From the docs, not run by us
{ "source": "/me", "destination": "/profile.html", "permanent": false }

Temporary redirect with status 307

From the docs, not run by us
{ "source": "/user", "destination": "/api/user", "statusCode": 301 }

Redirect with an exact status code; can't be combined with permanent

From the docs, not run by us
"headers": [{ "source": "/:path*", "headers": [{ "key": "X-Frame-Options", "value": "DENY" }] }]

Add a response header to every path

Try it: http-header-generatorFrom the docs, not run by us
"cleanUrls": true

Drop .html from URLs; requests with the extension get a 308 to the clean path

From the docs, not run by us
"trailingSlash": false

308-redirect /about/ to /about; true does the reverse

From the docs, not run by us
"functions": { "api/report.js": { "maxDuration": 30 } }

Let one function run up to 30 seconds, within your plan's limit

From the docs, not run by us
"crons": [{ "path": "/api/cron", "schedule": "0 10 * * *" }]

Call a path on a schedule (schedule string up to 256 characters)

Try it: crontab-translatorFrom the docs, not run by us
vercel crons add --path /api/cron --schedule "0 10 * * *"

Add the same cron entry from the CLI (beta command)

From the docs, not run by us

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_TOKEN on the command line in CI.

    Export VERCEL_TOKEN as 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 redirects for moved pages.

  • Setting both permanent and statusCode on one redirect.

    The docs say statusCode can't be combined with permanent. Pick one.

  • Adding a vercel.ts next to an existing vercel.json and expecting both to apply.

    Only one config file is allowed per project. Move everything into the file you keep.

  • Forgetting vercel link in a fresh clone and getting prompts or the wrong project.

    Run vercel link once per checkout, then vercel env pull to fill in local variables.