Skip to content

Static exports

Deploy a Next.js app built with output 'export', and what it cannot do.

View as Markdown

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: /about for about.html, and /about/ when trailingSlash is on.
  • redirects in next.config.
  • headers in next.config, unless the app sets basePath.
  • The 404 page 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 GET and HEAD. 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.