Cloudflare Pages

Free hosting for static sites on Cloudflare's global network, with HTTPS, custom domains, and a preview URL for every branch.

What it is

A host for static sites and small server functions. You give it a folder of built files (Astro’s dist/), and it serves them from Cloudflare’s data centers around the world with HTTPS and your own domain. Every deploy gets its own URL, and every branch gets a preview URL, so you can check a change before it reaches main.

Server routes run as Cloudflare Workers. Add Astro’s adapter (npx astro add cloudflare) and endpoints like a form handler or a Stripe webhook deploy alongside the pages.

When to use it

  • Landing pages, docs, and marketing sites: the free plan covers unlimited static requests and bandwidth.
  • Astro sites with a few server routes (forms, webhooks, a chat endpoint).
  • When you already use Cloudflare for DNS, since the custom domain setup takes a minute.

When NOT to

  • Long-running or heavy server work. Workers have CPU time limits per request and don’t run Node’s full standard library, so code that needs the filesystem or native modules belongs on a Node host or a VPS.
  • Scheduled jobs. Pages projects can’t have Cron Triggers; use a separate Worker (see Run Background Jobs).
  • For a brand-new full-stack app, Cloudflare now points people toward Workers with static assets, which covers the same ground plus cron and more bindings. Pages still works well and is what this site runs on.

Gotchas worth knowing up front

  • Environment variables are set per environment. Production and Preview each have their own list in the dashboard; a variable added to one isn’t in the other.
  • Secrets for server routes are read at runtime, not baked in at build time. Set them in the Pages dashboard, not only in your CI.
  • Proxied DNS and email don’t mix. Mail records (MX, SPF, DKIM) must be “DNS only”.