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 AstroBeginner 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: Create a config file
  3. Step 3: Build and deploy
  4. Step 4: Make updates
  5. Deploy automatically from GitHub
  6. Common problems
  7. Frequently asked questions

Cloudflare Workers is where this site lives, so these are the exact steps we used. You’ll need a free Cloudflare account and a finished Astro site.

Step 1: Install Wrangler

Wrangler is Cloudflare’s command-line tool. Add it to your project:

npm install wrangler@latest --save-dev

Step 2: Create a config file

Create a file called wrangler.jsonc in your project folder, 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 so you can log in to Cloudflare. After that, it uploads your dist folder and prints your new address, which ends in workers.dev.

Open it. Your site is online.

Step 4: Make updates

Every 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 automatically from GitHub

If your project is on GitHub, Cloudflare can build and deploy it for you on every push. In the Cloudflare dashboard, go to Compute, then Workers & Pages, create an application, and import your repository. Set the build command to npx astro build and the deploy command to npx wrangler deploy.

We haven’t set this up for AstroBeginner 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, and that directory points to ./dist.
  • Old content 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 documentation says requests for static files are free and unlimited, and the free account is enough to deploy. Server code is billed separately once you pass the free tier.

Should I use Cloudflare Pages or Workers?

Workers. Both Astro and Cloudflare recommend 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 under Settings, Domains and Routes.

Stuck on a step?

Check the common errors guide, look up a word in the glossary, or ask in the official Astro Discord, where the support channels are friendly to beginners.

Keep reading

  1. How to Add Tailwind CSS to Astro

    Add Tailwind CSS to an Astro site with one command, then style your first element. Tested on Astro 7.4 and Tailwind 4.

    Tutorials, 5 minute read, November 6, 2026

  2. How to Add Images to an Astro Site

    Add an image to your Astro site, and let Astro shrink and convert it automatically. One test image went from 62 kB to 5 kB.

    Tutorials, 6 minute read, November 6, 2026

  3. How to Add a Sitemap to Astro

    Create a sitemap for your Astro site in three steps, so search engines can find every page. Includes the robots.txt line.

    Tutorials, 4 minute read, November 6, 2026

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