Static exports
Deploy a Next.js app built with output 'export', and what it cannot do.
An app with output: 'export' deploys like any other: import its repository and push. Every page
becomes a file served straight from the edge.
next.config.ts
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
output: 'export',
images: { unoptimized: true },
};
export default nextConfig;What works
- Every page, served at the path a static host would serve it at:
/aboutforabout.html, and/about/whentrailingSlashis on. redirectsinnext.config.headersinnext.config, unless the app setsbasePath.- The
404page the build writes, for any path without a file.
What does not
- Rewrites. As with
next export, a rewrite finds no page behind it. - Image optimization. Set
images.unoptimized, or use a loader of your own. - Methods other than
GETandHEAD. They are answered with the not-found page. - Very large sites. A deployment holds at most 4,000 distinct files, the server code's modules included, and each page is several of them (its HTML and its payloads), so a static export is limited to several hundred pages.
After a new deployment, a page still open from the previous one loads its next page fully instead of navigating on the client.