Skip to content

Cloudflare Pages

When Git integration is enabled, Cloudflare Pages builds pushes to the configured production branch and creates preview deployments for pull requests. Configure the build and branch settings in the Cloudflare dashboard.

Pull requests get automatic preview deployments, so you can review changes before merging to master.

Terminal window
pnpm build
# Deploy via wrangler
npx wrangler pages deploy dist --branch=master
# Or via Cloudflare Dashboard
# Project: astro-cloudflare

Set these in the Cloudflare Pages dashboard when your site needs them:

Variable Purpose
SITE_URL Canonical URL of your site
PUBLIC_GA_MEASUREMENT_ID Optional Google Analytics measurement ID
PUBLIC_GTM_ID Optional Google Tag Manager container ID

The R2_MEDIA binding in wrangler.jsonc connects to a Cloudflare R2 bucket for larger media assets. Configure the bucket and its public asset URL, then reference the assets from your content. Remove the binding if you don’t need R2.

  • master — Production builds
  • Feature branches — Preview builds triggered from pull requests