Module P-15·25 min read

Vercel zero-config and preview deployments, self-hosting with standalone output, static exports for CDN-only deployments, Docker multi-stage builds, PWA setup, and GitHub Actions CI pipelines.

JJS
Written by Jatin Jain Saraf · Senior Software Engineer

P-15 — Deployment and CI/CD Pipelines

Who this is for: Practitioners ready to ship. You've built the application — now you need to understand where it can run, what the trade-offs are between deployment targets, and how to build a CI/CD pipeline that catches problems before they reach users. This module covers the full deployment matrix: Vercel, self-hosted Node.js, Docker, and static export.


Three Deployment Targets

Every Next.js application can be deployed in three fundamentally different ways, and the choice affects which features work:

Vercel — zero-configuration, all features supported, preview deployments per PR, built-in ISR/PPR/edge compute. The path of least resistance and the right choice for most applications.

Self-hosted Node.js (standalone output) — full Next.js feature support (ISR, streaming, Server Actions, Route Handlers), requires a persistent Node.js process or container orchestration, more operational overhead.

Static export — pure HTML/CSS/JS files served from any CDN. No server required, no ISR, no Route Handlers that use Node.js APIs, no dynamic routes without workarounds. The right choice when you genuinely need zero server dependency.

The decision is not about preference — it's about which features your application uses.


Vercel Deployment

Vercel is the path with the least distance between code and production. Push to your main branch, it deploys. No configuration required for a Next.js application — Vercel detects it automatically and configures the build correctly.

Environment variables per environment:

bash

The Vercel CLI lets you pull remote env vars into a local .env.local:

bash

Preview deployments are the feature that pays for itself in minutes. Every pull request gets its own live URL — https://my-app-git-feature-branch-team.vercel.app. Your team reviews real running code, not static screenshots. Preview deployments use the Preview environment variables, so they can point at a staging database.

Zero-downtime deploys are automatic on Vercel. The old version continues serving traffic until the new deployment is ready. Instant rollback to any previous deployment via the dashboard or CLI:

bash

Standalone Output — Self-Hosting

For self-hosted deployments, enable standalone output in next.config.ts:

ts

After npm run build, Next.js generates .next/standalone — a minimal self-contained directory with only the Node.js server and its actual runtime dependencies (no node_modules bloat from dev dependencies or unused packages). Typical size reduction: from 500MB to 40–80MB.

The standalone server runs with:

bash

You need to copy two additional directories alongside the standalone output — Next.js doesn't include them automatically:

bash

Docker Multi-Stage Build

Sign in to keep reading

The rest of this module is free — sign in with Google to unlock it and track your progress.

Sign in & Register

Discussion

0

Join the discussion

Loading comments...

© 2026 Jatin Jain Saraf (JJS). All rights reserved.