A practical guide to setting up Vercel deployments, environment variables, and preview environments for Next.js projects.
Vercel is built by the team that created Next.js. Deployments are zero-config — push to GitHub and your app is live in under a minute. Every pull request gets its own preview URL, making it easy for clients to review changes before they go live.
next buildThat's it for a basic deployment.
Never commit .env files. Set variables in the Vercel dashboard under Settings → Environment Variables. Scope them per environment:
| Variable | Production | Preview | Development |
|---|---|---|---|
DATABASE_URL | Neon prod branch | Neon dev branch | Local |
NEXTAUTH_SECRET | ✓ | ✓ | ✓ |
GOOGLE_CLIENT_ID | ✓ | ✓ | — |
Pull them locally with the Vercel CLI:
pnpm dlx vercel env pull .env.localEvery branch and pull request gets a unique URL like my-app-git-feature-xyz.vercel.app. Share these with clients for sign-off before merging. Preview deployments use their own environment variable scope so they can point to a staging database.
In Settings → Domains, add your domain and point the DNS records as instructed. Vercel handles SSL automatically via Let's Encrypt.
Next.js App Router uses a combination of static, dynamic, and streaming rendering. Vercel caches static pages at the edge globally. For ISR pages, set revalidate:
export const revalidate = 3600; // revalidate every hourFor on-demand revalidation after a CMS update:
import { revalidatePath } from "next/cache";
revalidatePath("/blog");pnpm build passes locally with no type errors