All guides

Deploying to Vercel with Claude Code: from local to live

Ship 10 min read

TL;DR

Deploying to Vercel with Claude Code in the loop comes down to a clean build config, environment variables managed in the dashboard, and the discipline to look at preview URLs before merging. This guide walks through linking the project, fixing the first failed build, configuring env vars, using previews as your real QA, and rolling back when something ships wrong.

Why Vercel pairs well with Claude Code

Vercel is opinionated about what a deploy looks like and that opinion lines up with how Claude Code likes to work. You push to a branch, Vercel builds a preview, and you get a URL to share before anything hits production. Claude Code can write the code, you can read the preview, and the loop closes quickly. There is no manual server provisioning, no Docker file you have to babysit, and no environment that drifts in mysterious ways. That makes it the right first deploy target for most new projects.

Linking the project

The first deploy starts with linking your local repo to a Vercel project. You can do this through the dashboard or with the Vercel CLI. The CLI flow is the one most builders end up preferring because Claude Code can drive it. Install the Vercel CLI globally, run vercel link inside your project folder, pick or create the project, and accept the defaults if you do not have a reason to override them. The CLI writes a small dotvercel folder you should add to git ignore.

  • Install the Vercel CLI with npm install -g vercel so the link command is available
  • Run vercel link from your project root with Claude Code watching the session
  • Pick an existing project or create a new one from this folder
  • Add the dotvercel folder to git ignore so the link metadata stays local
  • Confirm the link by running vercel project to see the project show up

Environment variables done right

Environment variables are where most first deploys break. Your local dot env file works, the build fails, and you spend an hour figuring out which variable was missing in production. Skip that hour. Open the Vercel project dashboard, add every variable your build needs, and label which environments each one applies to. Production, preview, and development each get their own set. Keep the names identical to your local file so there is no translation needed.

Building for the right framework

Vercel auto detects most frameworks. Next.js, Astro, SvelteKit, Vite, and Remix all just work without configuration if the framework is one of the supported ones and your package json scripts follow convention. If you are doing something custom, you can override the build command, the output directory, and the install command in the project settings. Get this right once at project setup and you stop thinking about it. Claude Code can confirm the right values by reading your package json and comparing to Vercel docs.

Lock your Node version in the project settings to match what you use locally. Vercel picks a sensible default but it can drift when the platform updates its base image. Pinning the version takes one minute and prevents a class of mysterious build failures where the same code builds at home and not in production. The same logic applies to the package manager. If you use pnpm locally, set Vercel to use pnpm too. Mixing managers across environments leaves you debugging lockfile diffs that should never exist.

Your first failed build

Your first deploy will probably fail. That is not a problem. The failure is information. Open the build log on Vercel and copy the error into your Claude Code session. The fix is almost always one of three things. A missing environment variable, a dependency that exists locally but is not in package json, or a build script that assumes a tool that is not present in the build container. Each has a fast fix. Add the variable, declare the dependency, or install the missing tool in the build command.

  1. 1Open the build log in the Vercel dashboard and read the error end to end
  2. 2Paste the relevant lines into Claude Code so it has the same context you have
  3. 3Decide if the fix is config, dependency, or environment, then make the change
  4. 4Push the fix as its own small commit so the history shows what each fix did
  5. 5Watch the new build run and confirm it goes green before moving on

Previews as your real QA

Every PR gets a preview URL. Treat that URL as where the real QA happens. Click through the pages, hit the API routes, sign in if there is auth, take a screenshot if you want a record. The preview is the truest answer to does this actually work. Local works is not the same as preview works. Many subtle bugs only show up in the preview environment because that is the first time the code runs against real env vars and a fresh build.

Promoting to production

Merging to main triggers a production deploy. Before you merge, run through the preview one more time and confirm nothing regressed. The production deploy itself usually takes the same time as the preview, which means you can watch it finish and check the live URL in one sitting. If the production build fails after the preview succeeded, the difference is almost always an environment variable that exists in preview but not in production. Check there first.

Rolling back without panic

Sometimes something ships that should not have. Vercel makes rollback trivial. Open the deployments list, find the last good production deploy, and promote it back to production. The bad deploy is still there in history if you want to inspect it. Promote does not destroy. It just makes the older build the live one again. Once production is back to good, switch to Claude Code, find the regression, write the fix, push a new branch, and let preview catch it before it ships again.

Monorepos and multiple projects in one repo

If your repo holds multiple apps under packages or apps folders, Vercel can host each as a separate project with its own root directory. Set the root in the project settings, point at the right package, and let each project deploy independently when its folder changes. This keeps deploys fast because each project only builds when its own code shifts. Claude Code is happy to work in a monorepo, and the rule of one slice per branch still applies. The deploys just stay scoped to the changed parts.

Static assets, images, and caching

Vercel caches static assets aggressively at the edge. That is great when assets are versioned by hash, which most frameworks do by default. It is painful when you assume a manual upload to a fixed path will refresh immediately and it does not. The fix is to let the framework version assets for you and to bust caches by deploying rather than by overwriting. When you do need to clear a path manually, Vercel exposes a purge in the dashboard. Use it sparingly, since aggressive purges undo the performance you are paying for.

Edge functions and where code runs

Vercel runs different parts of your app in different places. Static assets at the edge, server functions in regions you pick, edge functions even closer to the user. Most stacks pick sensible defaults and you do not have to think about this. When you do, it tends to matter. An edge function cannot use Node specific APIs. A server function can. Picking the wrong runtime for a route shows up as a deploy that builds fine and fails the first time it runs. Read the docs for your framework once, decide which routes run where, and let Claude Code keep them consistent.

Preview cookies and shared sessions

Preview deploys get their own URL and their own cookie scope. If your app uses cookies for auth, signing into the production URL does not sign you into the preview, and vice versa. This is correct behavior but it can surprise you the first time. Plan for it. When you QA a preview, sign into the preview directly. When you share a preview with a teammate, tell them they will need to sign in to the preview URL even if they are signed into production in another tab.

Custom domains and the certificate flow

Once the project is live on the Vercel default URL, point a real domain at it. Add the domain in the project dashboard, follow the DNS instructions Vercel shows, and wait for the certificate to provision. The wait is short but it is not instant. Plan the cutover for a quiet time of day. Once the certificate is in place, Vercel handles renewals automatically. You do not have to think about expirations again unless you move providers.

If you are migrating an existing domain, set the TTL on the relevant DNS records to a low value a day before the cutover. Lower TTL means the change propagates faster when you flip it. After the move is stable, raise the TTL back to its normal value. This single trick takes most of the surprise out of domain moves and Claude Code can help you draft the exact records you need to change.

Cron and background jobs

When your project grows past a simple site, you usually need scheduled work. A daily digest, a weekly cleanup, a nightly export. Vercel supports cron through scheduled function triggers configured in the project. Claude Code can write the function and the schedule config in one pass. Keep cron functions small and idempotent. If a run fails, the next run should be able to pick up the work without producing duplicates. The discipline of idempotency is what keeps scheduled work boring, which is the goal.

Logs, analytics, and what to watch

Vercel ships function logs in the dashboard for every deploy. Open them when something looks wrong. The logs tell you which routes are erroring, how long each invocation took, and what the error text was. For a small site you might never need them. For anything with auth or external API calls, they are the first place to look when a user reports something odd. Pair them with whatever analytics fits your project. Vercel Analytics works, Plausible works, even a simple log table in your database works. Pick one and check it weekly.

A repeatable per project workflow

After two or three projects this loop becomes muscle memory. Link the project on day one. Add env vars in the dashboard before the first push. Use previews as QA. Promote when the preview is green. Roll back without panic when something slips. The discipline is small enough that you can teach it to a teammate in an afternoon and reliable enough that you stop thinking about deploys as a separate kind of work. For the git habits that pair with this deploy loop, the /guides/git-workflow-with-claude-code guide is the natural next read, and the club at claudecodeclub.ai keeps a list of common Vercel pitfalls per framework.

Common questions

  • Why does Vercel pair well with Claude Code?

    You push to a branch, Vercel builds a preview, and you get a URL to share before anything hits production. Claude Code writes the code, you read the preview, and the loop closes quickly without manual server work.

  • How do I link my local project to Vercel?

    Install the Vercel CLI with npm install -g vercel, run vercel link from your project root, pick or create the project, and add the dotvercel folder to git ignore.

  • Where should environment variables live?

    In the Vercel project dashboard. Add every variable your build needs and label which environments they apply to. Keep names identical to your local file so no translation is needed.

  • Why did my first deploy fail?

    Almost always one of three things. A missing environment variable, a dependency that exists locally but is not in package json, or a build script that assumes a tool not present in the build container.

  • How do I use preview URLs for QA?

    Treat the preview URL as where the real QA happens. Click through pages, hit API routes, and sign in if there is auth. Local works is not the same as preview works.

  • What is the rollback process if a bad deploy reaches production?

    Open the deployments list in Vercel, find the last good production deploy, and promote it back. Promote does not destroy the bad deploy, it just makes the older build the live one again.

More guides

Go from reading to shipping

Guides get you oriented. The club gets you shipping. Join Claude Code Club for $9/month.

Related: the library, use cases, and the learn hub.