How do you deploy Next.js on Vercel vs self-hosted?
On Vercel, you connect a Git repository and every Next.js feature works with zero configuration: CDN for static shells, functions for request-time rendering, a shared data cache for ISR and use cache: remote, image optimization and preview deployments. Self-hosting runs next start (often in Docker with output: "standalone") and also supports every feature, but you configure caching, CDN, scaling and image optimization yourself.
Vercel
- Builds per commit, with preview URLs per branch or PR.
- Static output on a global CDN; request-time work on Fluid compute functions.
- Built-in durable cache for ISR, tags and remote caching; on-demand revalidation propagates globally.
- Image optimization, analytics, Speed Insights, firewall.
- Skew protection between deployments.
Self-hosting on Node.js
next buildthennext start, ornode server.jswith standalone output, behind Nginx or a load balancer.- Caching: by default ISR and
use cacheentries live on local disk and memory. With multiple instances, configurecacheHandlers(foruse cache) andcacheHandler(for ISR and fetch) backed by Redis or similar, so instances share entries and revalidation. - Encryption key: set
NEXT_SERVER_ACTIONS_ENCRYPTION_KEYso all instances accept the same Server Function IDs. deploymentIdfor version skew protection.- Images: the optimizer needs
sharp(auto-installed) and CPU; or use a custom loader and a CDN. - Streaming: disable proxy buffering.
- CDN: put a CDN in front for
/_next/static(immutable) and static shells.
Other platforms
Netlify, Cloudflare (OpenNext), AWS (OpenNext, Amplify), Render and Railway use the Adapters API (stable in 16.2) or OpenNext to map Next.js output to their infrastructure.
Static only
output: "export" to any static host, with the feature limits of static export.
Code example
1// next.config.ts (self-hosted, multi-instance)2import type { NextConfig } from "next";34const nextConfig: NextConfig = {5 output: "standalone",6 cacheComponents: true,7 cacheHandlers: {8 remote: require.resolve("./cache/redis-use-cache-handler.js"), // for "use cache: remote"9 },10 cacheHandler: require.resolve("./cache/redis-isr-handler.js"), // ISR / fetch cache11 cacheMaxMemorySize: 0, // rely on the shared cache instead of per-instance memory12 deploymentId: process.env.GIT_SHA,13};1415export default nextConfig;1617// Environment for every instance18// NEXT_SERVER_ACTIONS_ENCRYPTION_KEY=<same base64 key everywhere>19// Nginx: proxy_buffering off; (keep streaming working)
Practice this question
Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the Next.js set.