May 28, 2025
If you're building a static site (or even a SSR one) with tools like Astro, Hugo, or Next.js, you can supercharge its performance by deploying it to the edge with Cloudflare Workers. This post walks you through the entire process, from generating your site and setting up a Worker project with wrangler, to configuring your site and going live. You'll also learn how to set up a custom domain. It's a step-by-step guide to getting your site fast, secure, and live on the edge in minutes!
Static sites are fast, secure, and easy to maintain, and when served from the edge, they’re nearly unbeatable in performance. In this post, I’ll walk you through the deployment process of a statically generated site (like one from Next.js, Astro, Hugo, or Eleventy) to Cloudflare Workers.
Whether you’re a fan of npm run build
or hugo -D
, this guide will help you serve your site directly from Cloudflare’s edge locations.
Before you begin, make sure you have:
export
, Eleventy, etc.)Generate your production-ready static files using your preferred framework. For example:
npm run build
This will output a directory like dist/
, out/
, or public/
— your final static site files.
Once created, you’ll be redirected to your Worker’s dashboard.
Make sure the wrangler
CLI is installed in your project:
npm install -D wrangler
From your terminal, link your local project:
npx wrangler init --from-dash <YOUR_WORKER_NAME>
This will generate a new wrangler.jsonc
file which contains all the configuration for your worker.
Almost there, now, let’s make sure everything works as exepected by previewing your project locally
npx wrangler dev
This will execute a local server on port 8787, so you can access your site on http://localhost:8787
Run the following to push your static site and Worker to Cloudflare:
wrangler deploy
You’ll receive a live URL like:
https://my-static-site.<your-subdomain>.workers.dev
To use your own domain:
example.com
). I will automatically add the corresponding DNS record and proxy through cloudflare network.Deploying static sites with the new Cloudflare Workers flow is faster and more intuitive than ever. By combining edge performance with developer-friendly tooling, it’s a fantastic choice for everything from blogs to full-scale documentation sites.
If you want to skip deploying your site manually via wrangler CLI, you can connect to a repository (Github or Gitlab) and configure build and deploy commands for a CI/CD-ready static hosting.
Happy deploying!