OxyPages

A Static Export Of Next.js: What Works And What Breaks

A Static Export Of Next.js: What Works And What Breaks

A static export of Next.js turns your app into plain files, but Next.js 16 fails on its own defaults. What still works, what breaks, and when to stay on Vercel.

The OxyPages Team · · 7 min read

You want your Next.js site on a plain static host, so you add one line to next.config.ts, run the build, and either get an error you've never seen or a site where half the images are broken.

Both are normal. A static export of Next.js is a real, supported mode, and for a marketing site, docs or a blog it works well. But it switches off every feature that needs a server, and the newest Next.js defaults make the first build fail before you've changed anything else.

I tested it on 8 November 2026 with a fresh create-next-app project on Next.js 16.4.5. Adding output: 'export' to the default config failed immediately. After two lines came out, the export built, and then one image silently pointed at a server route that doesn't exist on a static host.

Below is the setting itself, what keeps working, the full list of what breaks with the error each one gives, and a straight verdict on when you should stay on a platform that runs Next.js as an app. If you're still choosing between frameworks, the React hosting options for a static build gives the wider picture.

TL;DR: Set output: 'export' in next.config.ts and next build writes a static site to out/. On a fresh Next.js 16 project, first remove cacheComponents and partialPrefetching, or the build fails with "PPR cannot be enabled in export mode". Server Components, client components, next/link and dynamic routes with generateStaticParams all work. Cookies, Server Actions, ISR, proxy (middleware), rewrites, redirects, headers, request-time route handlers and default image optimisation don't. Set images.unoptimized: true or use a custom loader. If you need any of the server features, stay on Vercel or another host that runs Next.js.

What Is A Static Export In Next.js?

It's a build mode where Next.js renders every route to HTML at build time and writes plain files you can upload anywhere. You turn it on with one setting, and the official Next.js guide to static exports (checked November 2026) describes the result as deployable "on any web server that can serve HTML/CSS/JS static assets."

// next.config.ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  output: 'export',
}

export default nextConfig

Run npm run build and the site lands in an out folder. The old next export command is gone: it was removed in Next.js 14 in favour of this setting.

The Error A Fresh Next.js 16 Project Gives First

On a project from today's create-next-app, adding output: 'export' isn't enough. The default config it generated for me already contained this:

cacheComponents: true,
partialPrefetching: true,

Cache Components makes Partial Prerendering the default rendering model, and partial prerendering needs a server to stream the dynamic part. With both settings in place, my build got to the last step and stopped:

> Build error occurred
Error: Invariant: PPR cannot be enabled in export mode

Deleting those two lines fixed it. The export built in a few seconds and wrote 920 KB to out/, most of it fonts and JavaScript chunks. The error doesn't tell you which setting to remove, which is why it's worth knowing in advance.

What Still Works In A Static Export

More than people expect. Next.js is designed so that most of the App Router survives an export:

  • Server Components run during next build, including any fetch they make, and their output is saved as HTML.
  • Client Components work as normal in the browser, including data fetching from public APIs.
  • next/link navigation stays fast. The export writes small .txt payload files next to each page, like index.txt, and the client fetches those when you click a link. Your host must serve .txt files for this to work.
  • Dynamic routes work if you list every value with generateStaticParams. In my test, app/post/[id] with two IDs produced post/1.html and post/2.html.
  • Route handlers work for GET only, and only when marked export const dynamic = 'force-static'. They render once at build time into a file, like data.json.
  • A 404 page. The export writes 404.html, which most static hosts serve for missing paths automatically.

What Breaks, And The Error You'll See

What Breaks, And The Error You'll See - OxyPages

Anything that needs a request to run breaks, because there's no request. The guide's own list of unsupported features is the authority here, and I triggered three of them to see how each one fails:

FeatureWhy it can't exportWhat happened in my test
cookies() and headers()There's no visitor request at build timeBuild failed: "couldn't be rendered statically because it used cookies()"
Dynamic routes without generateStaticParamsNext.js doesn't know which pages to writeBuild failed: "missing generateStaticParams()"
Image optimisation with the default loaderIt's a server route, /_next/imageBuild passed. The image pointed at /_next/image?url=... and broke on a static host
Server ActionsThey send a request to a server to runNot tested; listed as unsupported
Incremental Static RegenerationPages regenerate on a server after deployNot tested; listed as unsupported
Proxy (formerly middleware)It runs before every requestNot tested; listed as unsupported
Rewrites, redirects and headers in next.configThe server applies them per requestNot tested; listed as unsupported
Route handlers that read the requestThey run per requestNot tested; listed as unsupported
Draft Mode and intercepting routesBoth need request-time logicNot tested; listed as unsupported

Server Actions are the clearest case. React's documentation on Server Functions says that when one is called from the browser, React "will send a request to the server to execute the function". With no server, there's nothing to answer.

The image row is the one to watch. Every other failure stops the build, so you can't ship it by accident. The image one shipped happily in my test, and the page would have shown a broken image icon on any static host.

The fix is one line:

const nextConfig: NextConfig = {
  output: 'export',
  images: { unoptimized: true },
}

After that, the same image came out as src="/hero.png". You lose resizing and format conversion, so compress your images before you add them. If you want optimisation back, the guide shows a custom loader that hands it to an image service like Cloudinary.

Redirects, Trailing Slashes And Other Host Details

A static export hands three jobs back to your host.

Redirects And Headers

Because next.config redirects and headers don't export, you set them on the host instead: a _redirects or _headers file on Netlify and Cloudflare Pages, vercel.json on Vercel, or server config on nginx. Put the file in public so the build copies it into out.

Trailing Slashes

By default the export writes /about as about.html. Most static hosts serve that for /about without help, but plain nginx needs try_files $uri $uri.html $uri/ =404; to find it. If your host prefers folders, set trailingSlash: true and the export writes about/index.html instead.

Every route has its own HTML file, so refreshing a page works without a single-page app fallback. You'd only hit a 404 on a route you didn't prerender. How to fix a 404 on refresh covers that case for apps that do need a fallback.

When To Stay On A Host That Runs Next.js

When To Stay On A Host That Runs Next.js - OxyPages

Here's the verdict. If your app uses any of the server features in the table, a static export is the wrong tool, and no static host can fix that for you.

Stay on Vercel if you rely on ISR, Server Actions, proxy, next/image with no extra setup, or route handlers that read the request. Vercel builds Next.js and runs every one of those features as part of the platform. Netlify and Cloudflare also run most of the server features through their own adapters, and what a Vercel alternative can and can't replace is worth reading before you move anything.

A static export makes sense when your site is content that changes on publish: a marketing site, documentation, a blog, a portfolio. For those, you give up nothing you were using, and the site becomes a folder you can host anywhere.

That's the only Next.js OxyPages serves. It hosts the files from out/, whether you upload them or connect the repository, and it runs no server code. If your project needs a single feature from the "breaks" table, host it on a platform that runs Next.js as an app.

Walkthrough: Turning A Fresh Next.js 16 App Into A Static Export

Here's the sequence that got my test project from error to working folder:

  1. Open next.config.ts and remove cacheComponents: true and partialPrefetching: true.
  2. Add output: 'export', plus the images.unoptimized setting shown above.
  3. Search your app folder for cookies(, headers(, "use server" and revalidate. Each hit needs rewriting or the export fails.
  4. Add generateStaticParams to every dynamic route, returning every value you want built.
  5. Run npm run build. Read the route table: every row should be ○ (static) or ● (generated from params), never ƒ.
  6. Open out/ and check there's an HTML file for each route, plus the _next folder.
  7. Serve out locally with any static file server and click through, watching the console for 404s.

What To Do Next

Run the build with output: 'export' and read the first error. It will tell you which server feature you're using. Then decide: if you can remove or replace it, keep going down the walkthrough. If you can't, the app needs a server.

Once out/ builds cleanly, put your Next.js export online with OxyPages by uploading the folder or connecting the repository.

FAQ

Can A Static Export Use The App Router?

Yes. Since Next.js 13.4 the App Router has supported exporting, including Server Components, which run once at build time. Features that read the request, like cookies or headers, are the ones you lose.

Why Are My Images Broken After A Static Export?

Your images still point at /_next/image, the optimisation route that only exists on a server. In my Next.js 16.4.5 test the build didn't warn about it. Set images.unoptimized: true in next.config.ts, or configure a custom loader, then rebuild.

Does A Static Export Support Dynamic Routes?

Yes, if you export generateStaticParams from the route and return every value to build. Without it, or with dynamicParams: true, the build fails because Next.js can't know which pages to write ahead of time.

Where Did The next export Command Go?

It was deprecated in Next.js 13.3 and removed in 14. Exporting is now the output: 'export' setting in next.config, and next build writes the result to out/.

Try It Now

Still Here? Drop It In.

The whole pitch fits in one sentence: your HTML, on a link, in seconds.

Drag and drop your HTML files, a folder, a ZIP, your app's build folder, a PDF, an image or an MP3

or ·

No account needed. Your unclaimed website stays live for 30 minutes on a free subdomain. Claim it to your account to keep it permanently.

  • No Account Needed
  • Free SSL
  • 30-Minute Unclaimed Link, Claim To Keep It