Back to Blog

Next.js Static Export Blank Page on Cloudflare Pages

Published: July 30, 2026
Next.js Static Export Blank Page on Cloudflare Pages

Next.js static export blank page on Cloudflare Pages is uniquely disorienting because the build log gives you nothing to work with — every step reports success, there's no error to search for, and the deployed URL just... doesn't show anything. Not a 404, not an error boundary, just white space. A successful build and a working deployed site are two separate claims, and this bug lives entirely in the gap between them: the build genuinely succeeded, and something about what Cloudflare actually publishes or how the browser resolves what it published is wrong.

Short answer: check the Build output directory setting in Cloudflare Pages first — it needs to match exactly where next build with output: 'export' actually writes files (out by default, or your configured distDir), and if that's already correct, check the browser's Network tab for failed JavaScript or CSS requests caused by a trailingSlash mismatch between what your export generated and what Cloudflare's routing expects.

Two hands holding up a completely blank white canvas against a plain background, representing a Next.js deployment that built successfully but renders nothing at all

The Most Common Cause: Wrong Build Output Directory

Cloudflare's own deployment guide for static Next.js sites specifies the build directory setting directly as out for a standard static export. Next.js writes every generated HTML, CSS, and JS file into that folder when output: 'export' is set — nowhere else, and nothing about the build process automatically tells Cloudflare which folder actually holds the output. If the Cloudflare Pages project's Build output directory setting points at anything else — a leftover default from before static export was configured, or a typo from copying settings between projects — the build itself completes without error, and Cloudflare faithfully publishes an empty or incorrect folder. The deploy log shows success because, from the build tool's perspective, it was one.

(If you've been re-triggering the deploy hoping a second attempt catches something different — it won't. The build isn't flaky here. It's correctly building the right files into the right folder; Cloudflare is just looking somewhere else for them.)

Fix: Confirm the Output Directory Matches Your Actual Config

Check next.config.js for whether distDir is customized:

JavaScript
1// next.config.js
2module.exports = {
3  output: 'export',
4  // distDir: 'dist', // only if you've explicitly changed it — otherwise it's 'out'
5};

Then confirm Cloudflare Pages' project settings under Build output directory match exactly — Cloudflare's own build configuration reference documents exactly where this setting lives and how it interacts with the build command — out unless you've deliberately renamed it, in which case that exact custom value needs to be reflected on the Cloudflare side too. This single mismatch, more than any code issue, accounts for a large share of "successful build, blank site" reports.

A red 'Wrong Way' road sign mounted on a pole against a cloudy sky, representing Cloudflare Pages configured to look for build output in the wrong directory

The Second Cause: trailingSlash Mismatches Breaking Asset Paths

If the output directory is confirmed correct and the page is still blank, Next.js's trailingSlash configuration reference is specific about what this setting actually changes: with it set to true, a route exports as /me/index.html instead of /me.html. That structural difference matters because it changes how relative asset paths resolve depending on the exact URL shape a browser requests. If your export used one structure but a link, redirect, or Cloudflare's own routing assumes the other, the HTML document itself can load successfully while the JavaScript and CSS it references — using paths that assumed a different URL depth — fail to resolve. The page renders as blank not because nothing loaded, but because nothing executable loaded: an empty root div with no script ever successfully attached to it.

Checking the Browser Console for the Actual Failing Request

Rather than guessing between these two causes, open the deployed URL directly and check the Network tab:

TEXT
1# What to look for in DevTools → Network, on the live deployed URL
21. Reload the page with DevTools open
32. Filter by "Fetch/XHR" and "JS" — look for anything red (404, failed)
43. Note the exact path requested — does it match a real file in your `out` folder?

If literally everything 404s, including the base HTML document itself, that points at the output-directory cause — Cloudflare has nothing at all to serve. If the HTML loads (visible in the Elements panel, populated but unstyled and non-interactive) while specific .js or .css requests fail, that's the trailingSlash/asset-path mismatch, and the exact failing path tells you precisely which structure your links or redirects are assuming incorrectly.

Close-up of computer screen code showing an HTML file:// URL and a button element, representing the exact failing asset path visible in browser developer tools

The Opinion Part

Here's the position worth stating plainly: a green checkmark on a build log is a claim about the build process, not a claim about the deployed product working — and treating them as the same thing is exactly how "the build succeeded" and "the site is blank" end up feeling like a contradiction instead of two separate facts that are both true at once. The fix here is never about making the build "more successful." It's about verifying the thing the build produced is actually the thing being served, at the paths the browser is actually requesting. That's a five-minute check in DevTools that replaces however long you'd otherwise spend re-triggering an already-correct build.

Conclusion

If a Next.js static export shows a blank page on Cloudflare Pages, don't trust the green build log as proof the site is actually working. Confirm the Build output directory setting matches where your export genuinely writes files — out by default — and if that's already right, check the Network tab on the live URL for the specific failing asset request, which will point directly at a trailingSlash or path mismatch between what your export generated and what Cloudflare is trying to serve.

If middleware or a specific adapter choice on Cloudflare is a separate concern on the same project, our Cloudflare Pages middleware guide covers that related but distinct platform quirk, and if the deeper question is which Next.js features actually survive static export at all, our dynamic server usage guide covers that broader list.

Point the platform at the folder the build actually filled, match the URL structure the export actually generated, and let the blank page turn back into the site you built.

Frequently Asked Questions

The most common cause is Cloudflare Pages being configured to serve from the wrong build output directory. next build with output: export writes static files to an out folder by default (or whatever distDir is configured), and if Cloudflare's project settings point at a different directory, the deploy succeeds because the build itself ran fine — it just publishes the wrong (or an empty) folder, leaving nothing for the browser to actually render.

out is the default when output: export is set without a custom distDir in next.config.js — if you've changed distDir, Cloudflare's Build output directory setting needs to match that exact value. This is a project setting configured directly in Cloudflare Pages, not something Next.js itself communicates to the platform automatically.

Yes, indirectly. Next.js's trailingSlash setting changes the actual file structure the export produces — /about/index.html when trailingSlash is true, versus /about.html when it's false. If Cloudflare's routing doesn't align with which structure your build actually produced, the page's HTML can still load while its JavaScript and CSS assets, referenced with paths assuming the other structure, fail to resolve — leaving a blank white page because the scripts needed to render anything never actually loaded.

Open the browser's developer tools Network tab on the actual deployed URL and reload — a blank page with a genuinely successful build almost always shows failed (404 or similar) requests for specific JavaScript or CSS files in that list. The exact failing path tells you directly whether it's an output directory problem (nothing loads at all, including the HTML) or an asset-path mismatch (the HTML loads, but its script and style references don't).

It depends on the specific cause. A wrong build output directory typically blanks the entire site, since Cloudflare is serving the wrong folder (or nothing) regardless of which route is requested. A trailing slash or asset-path mismatch can be route-specific, particularly affecting nested routes more than the homepage, since relative asset paths are more likely to resolve incorrectly the deeper a route sits in the URL structure.

Portrait of Umar Farooq

About Umar Farooq

Umar Farooq is the founder and lead engineer of Codify SaaS. He builds B2B SaaS products and web applications on modern TypeScript stacks and enterprise Java, and writes code-first guides drawn from real production work — the schema decisions, the migrations that almost went wrong, and the performance fixes that actually moved the numbers. When he recommends an approach, he shows the code and explains the trade-offs.

Read full bio