Cloudflare Pages
Introduction
Cloudflare Pages is the recommended deployment target for ReeWeb sites. It reads the _redirects file natively, provides a global CDN with automatic HTTPS, and has a generous free tier. This page covers manual and automated (Git-based) deployment.
Why Cloudflare Pages
_redirectsnative support - ReeWeb emits_redirectsin Cloudflare's format, so 301/302 redirects work at the edge without any configuration.- Global CDN - 330+ data centres, automatic HTTPS, HTTP/3 support.
- Free tier - 500 builds per month, unlimited sites, 1 GB storage.
- Automatic Git integration - connects to your GitHub or GitLab repository.
Manual Deployment
Upload the contents of dist/ to Cloudflare Pages manually:
- Generate the site:
bun ssg - Go to the Cloudflare Dashboard → Pages
- Click Create a project → Direct Upload
- Drag and drop the
dist/folder - Set the production URL and deploy
This works for one-off deployments. For ongoing updates, use Git integration instead.
Git Integration
To connect your repository:
- Push your project to GitHub or GitLab
- Go to Cloudflare Pages → Create a project → Connect to Git
- Select your repository
- Configure the script settings:
| Setting | Value |
|---|---|
| SSG command | bun ssg |
| Build output directory | /dist |
| Root directory | (leave blank - project root) |
| Environment variables | Add SITE_URL=https://yourdomain.com |
Cloudflare Pages detects Bun automatically from the bun.lock file. No additional configuration needed.
Redirects on Cloudflare
ReeWeb's _redirects file is emitted automatically when you declare redirects in config/redirects.ts. Cloudflare Pages reads this file at the edge - redirects are applied before any HTML is served, which means zero round-trips for redirect traffic.
The _redirects format includes both trailing-slash and non-trailing-slash variants:
/old-page /new-page 301
/old-page/ /new-page 301
This ensures both /old-page and /old-page/ redirect correctly.
Custom Domain
In the Cloudflare Pages dashboard:
- Go to your project → Custom domains
- Click Set up a custom domain
- Enter your domain and follow the DNS instructions
- Cloudflare automatically provisions an SSL certificate
If your domain is already on Cloudflare, the DNS is configured automatically. If not, Cloudflare will give you nameservers to update at your registrar.