← Next.js learning path
Next.js · Module 10 of 10

Deploying Next.js

Ship to Vercel, a Node server, Docker or static hosting.

📖 Key ideas

  1. npm run build then npm start runs a production server.
  2. Vercel deploys from Git automatically with previews.
  3. output: "standalone" makes slim Docker images.
  4. output: "export" creates static files for any host.
  5. Set environment variables per environment; NEXT_PUBLIC_ ones are exposed to the browser.
💡 Real-life example: Deploying is moving into a new house: pick the house type (Vercel, server, static) that fits your furniture (features).
npm startRuns the built Next.js server
standaloneOutput mode for minimal servers/Docker
NEXT_PUBLIC_Prefix for browser-visible env vars
Preview deploymentTemporary URL for each branch/PR