Beginner Astro Blog with Tailwind & Cloudflare
Part 4: Cloudflare Workers & Deployment
Configure Astro’s Cloudflare adapter, set up wrangler.jsonc, and deploy your blog to Cloudflare Workers using both the CLI and the Cloudflare dashboard.
In this final part, you’ll connect everything to the real world: Cloudflare Workers. We’ll configure Astro’s Cloudflare adapter, set up Wrangler, and walk through both the command line and the Cloudflare dashboard so you can see where everything lives.
By now you have:
- An Astro v5 blog with Tailwind CSS v4
- A small design system and base layout
- Content collections, layouts, and components
Now we’ll make it public and fast, using Cloudflare’s edge network.
Step 1 - Install the Cloudflare Adapter for Astro
Astro needs an “adapter” to know how to run on Cloudflare Workers.
For more on the Cloudflare adapter:
- Astro Cloudflare Adapter Guide: https://docs.astro.build/en/guides/integrations-guide/cloudflare/
Install the official Cloudflare adapter:
npm install @astrojs/cloudflare
Step 2 - Configure astro.config.mjs for Cloudflare Workers
Open astro.config.mjs and wire up the adapter:
// astro.config.mjs
// @ts-check
import { defineConfig } from 'astro/config'
import cloudflare from '@astrojs/cloudflare'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
site: 'https://your-domain.example', // update this later to your real domain
output: 'server',
adapter: cloudflare({
platformProxy: {
enabled: true,
},
imageService: 'compile',
}),
vite: {
plugins: [tailwindcss()],
},
// integrations: [...] // (astro-icon, mdx, etc., if you use them)
})
Key parts:
output: "server"tells Astro to build for a runtime like Cloudflare Workersadapter: cloudflare(...)makes sure Astro generates a_worker.jsentry for Wranglersiteshould eventually match the domain you configure in Cloudflare
For more on Astro output modes and Cloudflare configuration:
- Astro Output Modes: https://docs.astro.build/en/basics/output/
- Cloudflare Image Service: https://developers.cloudflare.com/workers/platform/images/
Step 3 - Create or Review wrangler.jsonc
Wrangler reads configuration from a wrangler.json or wrangler.jsonc file in your project root.
For complete configuration reference:
- Wrangler Configuration Reference: https://developers.cloudflare.com/workers/wrangler/configuration/
Create wrangler.jsonc if you don’t have it yet:
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "my-astro-blog",
"main": "./dist/_worker.js/index.js",
"compatibility_date": "2025-11-27",
"compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],
"workers_dev": false,
"send_metrics": false,
"routes": [
{
"pattern": "your-domain.example",
"custom_domain": true,
},
],
"assets": {
"binding": "ASSETS",
"directory": "./dist",
},
"observability": {
"enabled": true,
},
}
Important fields:
name- the Worker’s name inside Cloudflaremain- the built Worker entry that Astro generatescompatibility_date- the API version; pick a recent date and update occasionallyroutes- how your Worker is attached to a domainassets- tells Cloudflare to serve static assets from yourdistdirectory
For more on compatibility dates:
- Cloudflare Compatibility Dates: https://developers.cloudflare.com/workers/platform/compatibility-dates/
If you don’t have a custom domain yet, you can temporarily set:
{
"workers_dev": true,
"routes": []
}
Cloudflare will then give you a https://my-astro-blog.your-account.workers.dev URL.
Step 4 - Log In with Wrangler
Before deploying, you need to link Wrangler to your Cloudflare account.
In your terminal:
npx wrangler login
This will:
- Open a browser window
- Ask you to log in to Cloudflare (if you’re not already)
- Request permission for Wrangler to manage Workers on your behalf
Once you see a success message, Wrangler is connected to your account.
For more on authentication:
- Wrangler Authentication: https://developers.cloudflare.com/workers/wrangler/authentication/
Step 5 - Build and Test Locally
Let’s make sure the Worker builds correctly before deploying.
From your project root:
npm run preview
Behind the scenes, this should:
- Run
wrangler types - Run
astro checkandastro build - Start
wrangler devusing the generated_worker.js
For more on local development:
- Wrangler Dev Mode: https://developers.cloudflare.com/workers/wrangler/commands/#dev
In the terminal you’ll see a local URL, often something like:
http://127.0.0.1:8787/
Open it in your browser. You should see your Astro blog, but now it’s running inside a Cloudflare Worker simulation.
If anything fails:
- Check the error message for missing environment variables or syntax issues
- Make sure
maininwrangler.jsoncpoints to the correct built Worker path
Step 6 - Configure Cloudflare via the Dashboard (Web UI)
Even if you prefer the CLI, it’s helpful to understand the Cloudflare dashboard. We’ll link your Worker to a domain and see where configuration lives.
6.1 - Create a Worker (if Wrangler hasn’t already)
For direct access to your Cloudflare dashboard:
- Cloudflare Workers Dashboard: https://dash.cloudflare.com
- Go to https://dash.cloudflare.com
- Choose your account
- In the left sidebar, click Workers & Pages
- Click Create → Worker
- Give it a name (for example,
my-astro-blog)
If you already deployed with Wrangler, you should see the Worker listed here; you don’t need to create a new one.
6.2 - Attach a Domain (Route)
If you have a domain managed by Cloudflare:
- In the dashboard, go to Workers & Pages
- Click your Worker (e.g.
my-astro-blog) - Go to the Triggers tab
- Click Add route
- Enter your domain pattern, for example:
example.comwww.example.com
- Click Save
This route should match the pattern you set in wrangler.jsonc. If you prefer, you can manage routes only in the UI and leave routes empty in the config.
For more on routing:
- Routing Requests to Workers: https://developers.cloudflare.com/workers/configuration/routing/routes/
6.3 - Environment Variables (Optional for Now)
If your Astro project uses secrets or environment variables:
- In your Worker’s page, go to the Settings tab
- Click Variables
- Add:
- Environment variables (non‑secret values like
APP_ENV) - Secrets (API keys, tokens, anything sensitive)
- Environment variables (non‑secret values like
Later, you can bind these to Astro’s runtime in server endpoints. For a simple blog that doesn’t call external APIs, you can skip this for now.
For more on environment variables:
- Cloudflare Environment Variables: https://developers.cloudflare.com/workers/configuration/environment-variables/
Step 7 - Deploy to Cloudflare Workers with the CLI
Once everything looks good locally, it’s time to deploy.
From your project root:
npm run deploy
This should:
- Generate Cloudflare types
- Type‑check and build your Astro project
- Upload the built Worker to Cloudflare
- Attach it to your routes (from
wrangler.jsoncor the dashboard)
If the deploy succeeds, Wrangler will print the URLs where your Worker is available.
Check both:
https://your-domain.example(if you attached a custom domain)https://my-astro-blog.<your-account>.workers.dev(ifworkers_devis enabled)
Step 8 - Basic Production Checklist
Before you call it done, quickly run through:
-
HTTPS working
Open the site in a browser and confirm the connection is secure. -
Navigation and content
Click through your homepage, blog index, and at least one post. -
Dark mode
If you implemented a theme toggle, test both light and dark. -
Performance Open DevTools → Network, refresh, and verify quick responses from Cloudflare’s edge.
For monitoring your Worker’s performance:
- Cloudflare Performance Metrics: https://developers.cloudflare.com/workers/observability/metrics/
If something feels off, you can:
- Run
npm run previewlocally again - Update your code or configuration
- Re‑deploy with
npm run deploy
Recap: From Zero to Deployed Astro Blog
Across all four parts, you:
- Part 1 - Created an Astro v5 project, added Tailwind CSS v4, and set up Wrangler scripts
- Part 2 - Built a design system with CSS variables and fontsource‑powered typography
- Part 3 - Used content collections, layouts, and astro‑icon to create a real blog
- Part 4 - Configured the Cloudflare adapter, set up
wrangler.jsonc, and deployed to Workers using both the CLI and the dashboard
You now have a beginner‑friendly, modern blog:
- Fast by default (Astro + Cloudflare edge)
- Easy to style (Tailwind CSS v4 with a design system)
- Comfortable for long‑form writing (layouts, typography, and components)
From here, you can keep iterating:
- Add a search modal or command palette
- Experiment with more content types (notes, docs, snippets)
- Integrate analytics or small interactive widgets
But the hard part getting from nothing to a deployed Astro + Tailwind + Cloudflare blog is done. Nicely done.