A blog does not need a server. With a static export, Next.js writes every page to HTML at build time, and Cloudflare serves those files from its edge.
One line of config
// next.config.mjs
export default {
output: 'export',
images: { unoptimized: true },
};
Run npm run build and the site lands in out/. Open any file in it and you will see finished HTML.
Connect the repository
In the Cloudflare dashboard, go to Workers & Pages, create a Pages project and connect your GitHub repository. Use these settings:
- Build command:
npm run build - Output directory:
out - Node version: set
NODE_VERSIONto22, or add a.node-versionfile
Every push to main deploys to production. Every other branch gets its own preview URL, which is handy for checking a post before it goes live.
Add the custom domain
Under Custom domains, add the bare domain and the www name. When the domain's DNS is already on Cloudflare, the records and the HTTPS certificate are created for you.
Why static
- Speed: files come straight from the nearest edge location.
- Cost: static requests on Pages are free.
- Safety: there is no server or database to attack.
