Static export and its limits
If your app never needs a server, Next.js can compile it to plain HTML, CSS, and
JavaScript — a static export. Set the output mode in next.config.js:
// next.config.js
module.exports = { output: 'export' };
Running next build writes an out folder of prerendered files that any static
host — S3, Nginx, GitHub Pages — can serve. Server Components still run, but only
at build time.
The trade-off is real: a static export disables every feature that needs a
server. Server Actions, Route Handlers that read the request, ISR, dynamic
rendering, Proxy, Draft Mode, and cookies() / headers() all stop working.
Image Optimization is off too unless you supply a custom loader:
// next.config.js
module.exports = {
output: 'export',
images: { loader: 'custom', loaderFile: './my-loader.ts' },
};
Route Handlers are limited as well — only the GET verb renders, and only when
you mark the handler force-static. Attempting a server-only feature errors during
next build (or next dev).
So choose static export only when the content is fixed at build time. If you later need a mutation or per-request data, you must move back to a server target.
You are about to answer a short quiz on output: 'export'.