The complete guide to deploying a Next.js application to Vercel — environment variables, custom domains, preview deployments, and production optimization.

Abdur Razzak
Full-Stack Web Developer
Vercel is built by the same team that created Next.js, making it the most seamless deployment platform for Next.js apps. It automatically detects your framework, configures the build pipeline, and handles edge caching for static assets. Features like Incremental Static Regeneration, Server Actions, Edge Middleware, and Image Optimization all work out of the box on Vercel without any additional configuration.
Before deploying, ensure your project builds locally without errors: run npm run build and check for TypeScript errors, missing environment variables, and broken imports. Move any sensitive credentials to .env.local (never commit this file to Git). Verify your next.config.js — specifically that any external image domains are listed in images.remotePatterns. A clean local build is the first prerequisite for a successful Vercel deployment.
Push your project to a GitHub repository. Sign up at vercel.com with your GitHub account, click 'New Project', and import your repository. Vercel automatically detects Next.js and sets the correct build command (npm run build) and output directory (.next). You only need to intervene if you have a monorepo — in that case, set the root directory to the Next.js app folder (e.g., apps/web or update-portfolio-website).
Go to your project's Settings → Environment Variables in the Vercel dashboard. Add every variable from your .env.local file. Choose which environments each variable applies to: Production, Preview, and Development. Variables prefixed with NEXT_PUBLIC_ are embedded in the client-side bundle at build time — ensure these are added before triggering the first production deployment. Never add secret keys as NEXT_PUBLIC_ variables.
In Vercel's project settings, go to Domains and add your custom domain. Vercel gives you DNS instructions — either point your domain's A record to Vercel's IP, or add a CNAME record. If your domain is managed by Vercel (you transferred it there), DNS propagates instantly. For external registrars, propagation takes 24-48 hours. Vercel automatically provisions and renews SSL certificates via Let's Encrypt.
Every Git push to a non-main branch creates a Preview Deployment with a unique URL. Share these URLs with clients or teammates for review before merging to production. Merging to your main branch triggers a Production Deployment. Use Vercel's deployment protection (password-protect preview URLs) for client projects with sensitive content. Monitor performance with Vercel Analytics — it shows real-user Core Web Vitals data from your visitors.