Phase 8: Deployment
Pushing to GitHub triggers Vercel to build and deploy automatically. Preview URLs for every branch, custom domain in ten minutes.
Phase 8: Deployment
In one line:
git pushis now the entire deployment process. Vercel detects Next.js, builds, deploys, and gives you a URL — including a preview URL per branch.
"Deployment" used to be a multi-day ordeal involving SSH keys, server provisioning, and reverse-proxy configs. Now you push code to GitHub and a URL appears. The interesting work in this phase isn't the deploy itself — it's the things that wrap around it: custom domains, preview environments, and separating dev/preview/prod environment variables.
What git push actually does
You set this up in Phase 4. Pushing to GitHub triggers Vercel to:
- Detect Next.js.
- Install dependencies (with Bun if you set it up).
- Run the build.
- Deploy to a unique URL.
- Promote
mainto your production domain.
Custom Domain
In the Vercel dashboard:
- Settings → Domains → Add Domain.
- Buy a domain (Vercel sells them, or use Cloudflare/Porkbun/Namecheap).
- Add the DNS records Vercel tells you to.
- Vercel automatically provisions SSL.
Total cost: $10–15/year for the domain.
Preview Deployments
Every branch and every PR gets its own URL. Share preview links with friends to get feedback before merging.
Environment Variables
Vercel has three environments by default: Development, Preview, Production. Set environment variables per-environment in the dashboard.
Tip: Use different Stripe keys (test vs live) and different database URLs for preview vs production.
You want to refactor the entire library page. Don't push it to main directly — instead:
git checkout -b refactor/library-page- Make all your changes; commit and push.
- Open the branch on GitHub. Vercel comments on the PR with a preview URL like
shelftrack-git-refactor-library-tonyx.vercel.app. - Click through the preview yourself. Send the URL to a friend. See if anything regressed.
- If broken: fix on the branch; the preview redeploys automatically.
- If clean: merge to
main. Production deploys.
The branch and preview can live for days. You can have ten of these open at once. Each gets its own isolated URL.
The most common solo deployment incident: shipping a test charge to a real customer's card, or a preview deploy emailing a production user. Fix it once, structurally:
- Stripe: test key for Development + Preview, live key only for Production.
- Database: preview database (a Neon branch is great) for Preview, prod database only for Production.
- Resend / email: sandbox mode (or a "throwaway" sender domain) for non-prod environments.
Vercel's per-environment env vars make this trivial — just toggle which env vars apply to which environment in the dashboard.
Common mistakes
- Pushing directly to
mainfor everything. It works until a half-finished commit takes prod down at 11pm on a Tuesday. The fix is a branch + preview URL for anything riskier than a typo — preview deploys are free, and the 30-second click-through catches most regressions. - Using the production database from the Preview environment. Your preview branch points
DATABASE_URLat prod, you test a schema migration, and now real users see the half-applied state. The fix is a Neon branch (or a separate test database) wired to the Preview environment — Neon makes spinning one up a single click. - Pointing the apex domain straight at Vercel and forgetting
www. Half your users typewww.yourapp.comand hit a stranger's NXDOMAIN page. The fix is to add bothyourapp.comandwww.yourapp.comin Vercel and pick one as the canonical redirect target. - Letting failed builds sit red for days. "I'll fix it later" turns into a week of "main is broken but I'm working on a branch." The fix is to treat a red build like a phone alarm — fix or revert within the hour, even if the fix is
git revert. A greenmainis non-negotiable. - Never reading the build log. Vercel reports "Deployment Ready" but the function bundle is 250MB and timing out. The fix is to actually open the build output once a month — bundle size, slow steps, warnings — before they become incidents.
Page checkpoint
Did the deployment flow stick?
RequiredWhat's next
→ Continue to Phase 9: Observability where three free tools cover almost all your monitoring needs.