Static export restrictions
What you need to know
A static export turns a Next.js application into files that an ordinary static web server can deliver. It is suitable when the published routes and their initial content can be determined at build time.
By the end, you can: identify runtime-only features; choose static hosting appropriately.
Select static output in next.config.ts
import type { NextConfig } from 'next';const config: NextConfig = {output:'export', trailingSlash:true};export default config;Expected behavior: A compatible production build would emit files such as out/catalog/index.html. This is a staged configuration.
How it works
With output: 'export', the build writes an out directory by default. Server Components may execute during the build, but there is no Next.js server at request time. A Client Component may still hydrate and handle interactions, or contact a separately hosted API. A finite catalog can enumerate its dynamic paths with generateStaticParams; a newly added slug needs a new build. Request-dependent cookies, Proxy, ISR, Server Actions, default server-based image optimization and request-dependent Route Handlers require capabilities that this export does not supply. Build-generated GET handlers with no request dependence are a different case. A custom image loader can reference a separate image service, or use unoptimized local images when appropriate. Keep private data out of generated HTML, payloads and assets. Choose explicit trailing-slash behavior and make the host map URLs to the actual emitted files.
Enumerate a finite catalog in app/books/[slug]/page.tsx
export function generateStaticParams(){return [{slug:'river'},{slug:'forest'}];}export const dynamicParams = false;export default async function Book({params}:{params:Promise<{slug:string}>}){const {slug}=await params;return <h1>{slug==='river'?'River Atlas':'Forest Guide'}</h1>;}Expected behavior: Two book routes are eligible for generation. A nonexistent slug should return a genuine missing-page response from the host, not a fabricated success page.
Common mistake
Do not copy a working development app to a static host and expect its runtime endpoints to survive. A blanket fallback to index.html can turn missing URLs into misleading HTTP 200 responses.
Practice and verification
Classify a public documentation site, a private order history and a live mutation endpoint. For the static case list expected output paths, test direct links and a missing slug using the staged route inventory.
Scope: Proposed Next.js 16.x / React 19, App Router with Cache Components disabled unless noted. Framework and browser examples are staged, not executed. Hypothetical costs are not actual provider rates.