Deploying to Vercel

Beginner · 6 min

Deploy a Next.js app to Vercel from Git or the CLI, tell preview from production deployments, scope environment variables, and see what each feature runs on.

Before thisBuild output and next build

Vercel · 6 min

Deploying to Vercel

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by VercelReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Vercel builds your project with the same next build you run locally, so the route table from your own build predicts what will be deployed.
  • Connecting a Git repository gives you a production deployment on pushes to the production branch and a preview deployment, with its own URL, for every other branch and pull request.
  • The first deployment of a new project is always a production deployment, even if it comes from a non-production branch or from the CLI without --prod.
  • Environment variables are scoped to Local, Preview, and Production; preview deployments do not see production values, and changing a variable needs a new deployment to take effect.
  • Vercel maps Next.js features onto its platform automatically: server rendering runs in Vercel Functions, ISR pages are cached and persisted, and next/image optimization happens on demand.

Why start here

Everything so far ran on your machine. The quickest way to put it on the internet is a platform that already knows what a Next.js build produces. Vercel makes Next.js, and its deployment path is the one the framework’s own docs list as a verified adapter, using the same public adapter API anyone else can use. This lesson is about that path. It is not the only one, and the next two lessons cover running the same build yourself.

What a deployment is

A deployment is one build of one commit, served at its own URL. Vercel installs dependencies, runs your build script, which is next build, and then provisions what the output needs. The route table from your own build is therefore a preview of the result: ○ routes become static files on a CDN, and ƒ routes run as functions.

Vercel’s Next.js page describes the mapping like this: server rendering runs in Vercel Functions, ISR pages are cached on the CDN and persisted to durable storage, streaming works through Route Handlers and Server Components, and next/image optimization happens on demand rather than at build time. The platform page adds that on Vercel the static shell of a Cache Components page is served with ISR while Vercel Functions stream the dynamic parts into it. None of that needs configuration.

Three ways to deploy

The video shows all three, in this order.

  1. From a template. Pick a Next.js template, which clones a starter into your Git provider and deploys it.
  2. From a Git repository. Import an existing repository in the dashboard. Vercel detects Next.js and fills in the build settings. After that, every push deploys.
  3. From the CLI. Install the CLI, run vercel from the project root, and answer the prompts. vercel --prod deploys to production.

Git is what you want for a team, because it ties deployments to branches and pull requests.

Preview and production

Vercel has three environments: Local, Preview, and Production. The rules for which deployment you get, from Vercel’s docs:

  • A push to the production branch, usually main, creates a production deployment and updates your production domains.
  • A push to any other branch, a pull request, or vercel without --prod creates a preview deployment.
  • Each preview has a branch URL that tracks the branch and a commit URL for that exact build.

One quirk: the first deployment of a new project is always production, whichever way you start it. It then builds with your Production variables, not Preview ones.

By default new projects start with Standard Protection, so a preview requires a signed-in Vercel account with access to the project. Production domains stay public. Share a preview with an outsider through a shareable link.

Environment variables

Each environment can have its own values, so a preview can point at a staging database while production points at the real one. Variables are fixed at build time for anything that reaches the client, so after changing one you need a new deployment. For local development:

vercel link
vercel env pull

vercel link ties the directory to a project, and vercel env pull writes .env.local. The rule from environment variables still applies: only NEXT_PUBLIC_ names reach the browser.

What stays your job

Vercel handles routing, caching, and scaling. It does not make your own code correct for production. Check that data fetching works in the Production environment, that each Server Action checks authorization itself, and that your security headers are set. Also note what the platform choice costs you: you now depend on one vendor’s pricing and limits. The adapter API exists so other platforms can offer the same fidelity, and the docs list the Bun adapter as verified too.

What the video covers

This is Vercel’s own video. From its description and chapters: it deploys a Next.js template (from 0:13), pushes changes to GitHub (2:05), and deploys with the Vercel CLI (4:11), ending at 5:44. Transcripts were unavailable, so the lesson does not claim anything beyond those chapters.

It was published in January 2024, so the dashboard screens will look different now. The three-path structure and the Git workflow have not changed. The runner-up, PedroTech’s December 2025 video, covers importing a Git repository, environment variables, and the dashboard in under five minutes, and it promotes the creator’s paid course.

Where this fits

You can now ship without owning a server. When you want to, or have to, run the same output yourself, self-hosting with Node.js and Docker is next.

Check yourself

  1. 01You push a commit to a feature branch of a project that already has deployments. What gets created?

    A preview deployment, with a branch-specific URL that always points at the latest commit on that branch and a commit-specific URL for that exact build. Only pushes to the production branch, or vercel --prod, create production deployments.

  2. 02Why might a brand-new project's first deployment surprise you?

    It is always a production deployment, even if you import from a branch that is not the production branch or run vercel from the CLI without --prod, so it builds with your Production environment variables.

  3. 03Do preview deployments use your production environment variables?

    No. They use variables scoped to the Preview environment, optionally overridden per Git branch. The exception is the first deployment of a new project.

  4. 04What does vercel env pull do, and why is it useful?

    Run after vercel link, it writes the project's development environment variables into .env.local so next dev uses the same configuration names and values as the deployed app.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark