How to Deploy a Next.js App on Vercel

August 2, 2026
12 min read
By Rahul Mishra
Deploy Next.js App on Vercel

Vercel is the platform built by the creators of Next.js, making it the natural — and most powerful — choice for deploying Next.js applications. With zero-configuration deployments, global edge CDN, automatic HTTPS, and seamless Git integration, Vercel turns a complex deployment pipeline into a process that takes just a few minutes.

In this guide you will go from a local Next.js project to a fully live, production-grade URL — step by step, with explanations for every decision along the way.

Prerequisites

  • A Next.js project (version 12 or later recommended)
  • Node.js 18+ installed on your machine
  • A GitHub, GitLab, or Bitbucket account
  • A free Vercel account (vercel.com)
  • Git installed and your project committed to a repository
1

Prepare Your Next.js Project

Before deploying, make sure your project is production-ready. Run the build command locally to catch any errors early:

Terminal
npm run build

If the build passes without errors, your project is ready. Also ensure the following:

  • All environment variables are noted — add them in Vercel's dashboard, not in .env files committed to Git.
  • Your package.json has a "build" script (Next.js projects have this by default).
  • There are no hard-coded localhost URLs in your code — use relative paths or environment variables instead.
  • Your .gitignore excludes node_modules, .env.local, and .next.
2

Push Your Code to Git

Vercel deploys directly from a Git repository. If you haven't already, initialize a repo and push your project:

Terminal
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/your-username/your-repo.git
git push -u origin main

Use GitHub for the smoothest experience — Vercel's GitHub integration is the most feature-rich and supports automatic deploy previews for every pull request.

3

Create a Vercel Account

Visit vercel.com and sign up for a free account. The Hobby plan is completely free and more than sufficient for most personal and professional projects. When prompted, choose Continue with GitHub (or your preferred Git provider) — this links your account and grants Vercel permission to access your repositories.

What Vercel's free Hobby plan includes:

Unlimited personal projects
100 GB bandwidth per month
Automatic HTTPS / SSL certificates
Global Edge Network (100+ cities)
Serverless Functions (Node.js, Edge Runtime)
Preview deployments for every Git push
4

Import Your Repository

Once logged in to Vercel, click Add New → Project from the dashboard. Vercel will list all repositories your Git account has access to. Find your Next.js project and click Import.

Vercel automatically detects that the project is Next.js and pre-fills the correct framework preset. You will see:

  • Framework Preset: Next.js (auto-detected)
  • Root Directory: ./ (change if your app is in a subfolder)
  • Build Command: next build (auto-filled)
  • Output Directory: .next (auto-filled)
  • Install Command: npm install (auto-filled)

You generally do not need to change any of these — Vercel handles Next.js out of the box, including App Router, Pages Router, Server Components, API Routes, and Middleware.

5

Configure Environment Variables

This is the step most beginners skip, causing their deployed app to break. Before clicking Deploy, expand the Environment Variables section and add every key your app needs — API keys, database URLs, and secret tokens.

Example environment variables
NEXT_PUBLIC_API_URL=https://api.yourservice.com
DATABASE_URL=postgresql://user:pass@host/db
NEXTAUTH_SECRET=your-random-secret-string
NEXTAUTH_URL=https://your-project.vercel.app

Important: Public vs. Private variables

Variables prefixed with NEXT_PUBLIC_ are exposed to the browser. Never prefix secrets, API keys, or database credentials with NEXT_PUBLIC_ — keep those server-only.

6

Deploy

Click Deploy. Vercel will clone your repository, install dependencies, run next build, and publish the output to its global edge network. The whole process typically takes 60–120 seconds for a fresh project.

You can watch the build logs in real time. Once complete, Vercel gives you a live URL:

https://your-project-name.vercel.app

That URL is immediately live, globally cached, and served over HTTPS — no extra configuration needed.

7

Connect a Custom Domain

To use your own domain (e.g. www.yoursite.com) instead of the .vercel.app URL, go to your project's Settings → Domains and add the domain. Vercel will display the DNS records you need:

DNS records to add at your registrar
TypeNameValue
A@76.76.21.21
CNAMEwwwcname.vercel-dns.com

Once DNS propagates (usually within minutes, up to 48 hours depending on your registrar), your custom domain will serve your app with a free, auto-renewing SSL certificate managed by Vercel.

8

Continuous Deployment — Automatic from Here

From this point on, every time you push code to your main branch, Vercel automatically triggers a new production deployment. Every other branch or pull request gets its own preview URL so you can test changes before they go live.

Push to main

Triggers an immediate production deploy. Your live site updates automatically.

Open a Pull Request

Vercel creates a unique preview URL for that branch — shareable with teammates or clients.

Rollbacks

Every deployment is saved. One click in the dashboard reverts to any previous version instantly.

Build Logs

Full real-time logs for every deploy. Diagnose failures without leaving the Vercel dashboard.

9

Deploy via Vercel CLI (Alternative)

If you prefer the terminal over the web dashboard, the Vercel CLI lets you deploy from anywhere in seconds:

Terminal
# Install Vercel CLI globally
npm install -g vercel
# Log in
vercel login
# Deploy (from your project folder)
vercel
# Deploy directly to production
vercel --prod

The CLI walks you through the same setup as the dashboard on first run, then subsequent deploys are a single command.

10

Common Issues and How to Fix Them

Build fails with "Module not found"

A package is in devDependencies instead of dependencies. Move it, or ensure your build command installs all deps.

Environment variable is undefined at runtime

Did you add it to Vercel's dashboard? Variables in .env.local are not committed to Git and won't be available on Vercel unless added manually.

API routes return 404

Make sure the files live inside app/api/ (App Router) or pages/api/ (Pages Router). Check that you're not accidentally excluding them via .vercelignore.

Images not loading after deploy

If using next/image with external sources, add the hostname to the remotePatterns array in next.config.js. For local images, ensure the path starts from /public/.

"NEXT_PUBLIC_ variable" is undefined in the browser

These variables are baked in at build time. After adding or changing them in the Vercel dashboard, trigger a new deployment — a redeploy is required.

Best Practices for Production

Use Vercel's built-in Analytics to monitor real user performance
Enable Vercel Speed Insights for Core Web Vitals tracking
Use ISR (Incremental Static Regeneration) for pages with dynamic data that doesn't change every request
Store secrets in Vercel's environment variable system — never in source code
Use Preview Deployments to test every PR before merging
Set up Vercel's Web Application Firewall (WAF) for production apps handling user data

Conclusion

Deploying a Next.js app on Vercel is genuinely one of the most frictionless deployment experiences in modern web development. The Git-based workflow, zero-config Next.js detection, preview deployments, and global edge network make Vercel the go-to choice for teams of all sizes — from solo developers shipping side projects to enterprises running high-traffic applications. Follow this guide once and you will have a workflow you can repeat in under two minutes for every project after that.

Next.jsVercelDeploymentWeb DevelopmentDevOps

Related Articles

Top Chrome Extensions Every Web Developer Should Know

Top Chrome Extensions Every Web Developer Should Know

Essential Chrome extensions to enhance your web development workflow.

Read More
10 Essential MacBook Pro Performance Tips

10 Essential MacBook Pro Performance Tips

Optimize your MacBook Pro for better performance with these proven tips and tricks.

Read More
How to Clean 'Other' Storage on MacBook Pro

How to Clean 'Other' Storage on MacBook Pro

Learn how to safely clean up the mysterious 'Other' storage category using Terminal.

Read More