Introduction
Vercel is one of the fastest ways to ship a Next.js application. Every push to GitHub triggers an automatic deployment—preview deployments for pull requests and production builds for the main branch. Here's exactly how to set it up.
Step 1: Initialize Git
cd your-nextjs-project
git init
git add .
git commit -m "Initial commit"Step 2: Push to GitHub
- Go to https://github.com/new and create a new repository (public or private—your choice).
- Copy the remote URL and run:
git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO.git
git branch -M main
git push -u origin mainStep 3: Import on Vercel
- Go to https://vercel.com/new and click Import Git Repository.
- Authorize Vercel to access your GitHub account and select your repository.
- Vercel automatically detects Next.js and configures the build command (
next build) for you.
Step 4: Add Environment Variables
Before clicking Deploy, expand Environment Variables and add all the keys from your .env.local:
DATABASE_URLNEXTAUTH_SECRETNEXTAUTH_URL— Set this to your Vercel URL (for example,https://your-project.vercel.app).CLOUDINARY_*keysSMTP_HOSTSMTP_USERSMTP_PASSADMIN_EMAIL
Step 5: Get Your Unique URL
After deployment, Vercel assigns a URL like your-project.vercel.app.
To use a custom subdomain:
- Open your project in the Vercel dashboard.
- Go to Settings → Domains.
- Enter your preferred subdomain (for example,
my-awesome-app.vercel.app). If it's available, you can claim it.
Step 6: Automatic Deployments
Every:
git push origin mainautomatically triggers a production deployment.
Pull requests also receive their own preview deployment URL, making it easy to share changes for testing and feedback before merging.
Conclusion
GitHub + Vercel provides a streamlined CI/CD workflow for Next.js applications. You get automatic HTTPS, a global CDN, preview deployments, and zero-configuration deployments—all available on the Hobby plan.