Free Astro tutorials for complete beginners.

Beginner's Guide to Astro

How to Deploy an Astro Site to Cloudflare Workers

Put your Astro site online with Cloudflare Workers in four steps. This is how Astro Nursery itself is hosted, so every step has been run for real.

Tested on Astro 7.4

Cover image for How to Deploy an Astro Site to Cloudflare Workers
In this guide
  1. Step 1: Install Wrangler
  2. Step 2: Make a settings file
  3. Step 3: Build and deploy
  4. Step 4: Make updates
  5. Deploy on its own from GitHub
  6. Common problems
  7. Frequently asked questions

Cloudflare Workers is where this site lives. So these are the exact steps we used. To deploy means to put your site online. You need a free Cloudflare account and a finished Astro site.

Step 1: Install Wrangler

Wrangler is Cloudflare’s command-line tool. That means you run it from your terminal. Add it to your project:

npm install wrangler@latest --save-dev

Step 2: Make a settings file

Make a file called wrangler.jsonc in your project folder. Put it next to package.json:

{
  "name": "my-site",
  "compatibility_date": "2026-11-06",
  "assets": {
    "directory": "./dist",
    "not_found_handling": "404-page"
  }
}

Change name to your site’s name. It becomes part of your address. Set compatibility_date to today’s date.

The not_found_handling line tells Cloudflare to show your 404.astro page for missing addresses. Without it, visitors see a plain error.

Step 3: Build and deploy

Run these two commands:

npx astro build
npx wrangler deploy

The first time, Wrangler opens your browser. Log in to Cloudflare there. After that, it uploads your dist folder. Then it prints your new address. The address ends in workers.dev.

Open it. Your site is online.

Step 4: Make updates

Each time you change your site, run the same two commands again. To save typing, add a script to package.json:

"scripts": {
  "deploy": "astro build && wrangler deploy"
}

Now npm run deploy does both.

Deploy on its own from GitHub

Is your project on GitHub? Then Cloudflare can build and deploy it for you on every push. A push is when you send your changes up to GitHub. In the Cloudflare dashboard, go to Compute, then Workers & Pages. Create an application. Import your repository. Set the build command to npx astro build. Set the deploy command to npx wrangler deploy.

We have not set this up for Astro Nursery yet. So those steps come from Cloudflare’s guide in the Astro docs.

Common problems

  • “not logged in”: run npx wrangler login.
  • A blank page or missing styles: make sure you ran astro build before wrangler deploy. Check that directory points to ./dist.
  • Old pages after deploying: refresh with the cache cleared, or wait a minute.

Prefer a different host? Compare them in the best hosting for Astro. Or use GitHub Pages instead.

Frequently asked questions

Is Cloudflare Workers free for a static site?

Cloudflare's docs say requests for static files are free and unlimited. The free account is enough to deploy. Server code is billed on its own once you pass the free tier.

Should I use Cloudflare Pages or Workers?

Workers. Both Astro and Cloudflare suggest Workers for new projects. Pages is kept for sites that already use it.

Can I use my own domain?

Yes. Your domain needs to be managed by Cloudflare. Then you add it to the Worker in the Cloudflare dashboard: go to Settings, then Domains and Routes.

Stuck on a step?

Check the common errors guide, look up a word in the glossary, or ask the friendly people in the official Astro and EmDash Discords. How to ask so people can help.

Keep reading

  1. How to Register a Domain Name and Connect It to Your Astro Site

    Buy a domain for about $11 a year, then point it at Cloudflare or Netlify. We did this for astronursery.com, and these are the exact steps.

    Tutorials, 8 minute read, November 8, 2026

  2. How to Add Google Analytics to an Astro Site (and a Simpler Option)

    Paste Google's tag into your Astro layout with one small change, is:inline, and it works on every page. Or use Cloudflare Web Analytics, which needs no cookie banner.

    Tutorials, 6 minute read, November 8, 2026

  3. How to Add a Contact Form to an Astro Site (No Server Needed)

    A static site can't receive form submissions on its own. A free form service can. Here's a working contact form in ten lines, with spam protection built in.

    Tutorials, 7 minute read, November 8, 2026

Try "blog", "deploy" or "EmDash".