NextjsDeploying to Vercel

Deploying to Vercel

Vercel is the company behind Next.js, and its hosting platform is built to run Next.js apps with essentially no configuration. Every App Router feature — Server Components, Server Actions, ISR, Middleware, the Image Optimization API — works out of the box, and the deployment flow is built around connecting a Git repository once and letting pushes drive deploys from then on.

Git-connected, automatic deployments

The typical setup is: import a GitHub, GitLab, or Bitbucket repository into a Vercel project once. From then on:

  • Every push to the production branch (commonly main) triggers a new production deployment automatically.

  • Every push to any other branch, and every pull request, gets its own preview deployment with a unique URL.

  • Vercel detects that the project is Next.js and picks the correct build command and output directory automatically — no build configuration to write.

First deploy from the CLI (alternative to the Git integration)

Bash
npm install -g vercel
vercel        # deploy the current directory, prompts for project setup
vercel --prod # deploy straight to production
Preview deployments for every pull request

Preview deployments are one of the most practical reasons teams pick Vercel. Every pull request gets a fully working, publicly reachable deployment of that branch — including a real backend for Server Actions and Route Handlers — that reviewers can click through before merging, instead of only reading a diff.

Environment variables
Environment variables are configured per project in the Vercel dashboard (Project Settings → Environment Variables), and can be scoped independently to Production, Preview, and Development environments. Variables prefixed with NEXT_PUBLIC_ are inlined into the client bundle at build time, exactly as they are locally; everything else stays server-only.

Environment

When it applies

Production

Deployments from the production branch

Preview

Deployments from pull requests and non-production branches

Development

Values pulled locally via vercel env pull

Pull environment variables down for local development

Bash
vercel env pull .env.local
Note
The free "Hobby" tier is generous enough for personal projects, side projects, and evaluation — it includes automatic HTTPS, a global CDN, Git-connected deploys, and preview URLs. Commercial use and team collaboration require a paid plan, and usage-based limits (build minutes, bandwidth, function execution) apply on every tier, so check current pricing before committing production traffic to it.