Deploying to Cloudflare Pages
Updated

The full walkthrough is in docs/04-cloudflare-pages.md. This post exists
mainly to demonstrate a second date in the frontmatter — note the “Updated”
line under the title, which only appears because updatedDate differs from
pubDate.
The short version
- Push the repo to GitHub.
- In the Cloudflare dashboard: Workers & Pages → Create → Pages → Connect to Git.
- Build command
npm run build, output directorydist. - Add any
PUBLIC_*variables from your.envto the Pages project settings — they are build-time values, so the build needs them. - Deploy.
Anything under functions/ is picked up automatically as a Pages Function and
served at the matching path, which is how /api/contact works without a
separate server.
What doesn’t work locally
Pages Functions and bindings (D1, KV, R2) don’t exist under plain astro dev —
that’s a static dev server. Use npm run pages:dev to build and serve through
Wrangler when you need to exercise them. The contact form is written to tolerate
the API being absent, so ordinary astro dev work is unaffected.