Cloudflare Workers

Cloudflare Workers is the recommended deployment target for ReeWeb sites. The included wrangler.jsonc deploys dist/ with Workers Static Assets: Cloudflare serves the generated HTML, CSS, JavaScript, images, and other files across its network without requiring a Worker script.

ReeWeb also emits a _redirects file that Workers Static Assets applies at the edge. If a site later needs per-request behavior, the same deployment can enable the included cf-worker.ts without moving to another Cloudflare product.

How ReeWeb Is Configured

A fresh ReeWeb project includes this active Workers configuration:

{
    "name": "your-site",
    "compatibility_date": "2026-06-29",
    "main": "./cf-worker.ts",
    "assets": {
        "binding": "ASSETS",
        "directory": "./dist",
        "not_found_handling": "404-page",
        "run_worker_first": true
    }
}

The installer replaces name with the project folder name. assets.directory tells Wrangler to upload the generated dist/ directory as part of the Worker deployment. main points at cf-worker.ts and run_worker_first: true routes every request through it before falling back to the static asset - so the shipped Worker code runs by default. It fetches the asset itself, then only rewrites the response when it's HTML with a [data-cf-edge] element present, so pages without that marker pass through untouched. See Optional Cloudflare Worker for what it does and how to remove it if you want asset-only serving.

Deploy with Wrangler

After installing and authenticating Wrangler, generate and deploy the site:

wrangler login
bun ssg
bun cf:deploy

The bun cf:deploy script runs wrangler deploy, which uploads the static assets declared in wrangler.jsonc, then prints the configured SITE_URL. The first deployment also receives a workers.dev URL for testing.

Share a Temporary Preview

To let someone open your generated site without deploying it, build the site and start Wrangler's temporary public tunnel:

bun ssg
bun cf:share

Wrangler prints a temporary public URL and keeps serving dist/ through your local process. Leave the command running while the preview is in use. This is convenient for review and testing; use bun cf:deploy for a persistent deployment.

Deploy on Push with Workers Builds

Cloudflare's Git integration can build and deploy the Worker whenever you push to GitHub or GitLab:

  1. In the Cloudflare dashboard, open Workers & Pages.
  2. Select Create application, then import your repository.
  3. Ensure the Worker name matches name in wrangler.jsonc.
  4. Configure the build and deploy commands:
SettingValue
Build commandbun ssg
Deploy commandnpx wrangler deploy
Root directoryProject root, or the relevant monorepo path
Build variablesSITE_URL=https://yourdomain.com

Workers Builds runs the static-site generation step and then deploys the resulting assets using the checked-in Wrangler configuration. Non-production branch builds can use preview versions without promoting them to production.

Redirects on Workers

ReeWeb writes dist/_redirects from declarations in config/redirects.ts. Workers Static Assets reads this file and applies matching redirects before serving an asset response:

/old-page /new-page 301
/old-page/ /new-page 301

These two forms ensure both /old-page and /old-page/ redirect correctly. Redirect rules in _redirects do not apply to requests handled by custom Worker code, so request-dependent redirects belong in cf-worker.ts when run_worker_first is enabled.

Custom Domain

The initial deployment is available on a workers.dev subdomain. For production, add a Custom Domain to the Worker in Cloudflare's domain and route settings. Cloudflare provisions TLS for the domain automatically.

If you later need HTML rewriting, request-aware redirects, or another edge behavior, enable the included Worker script as described in Optional Cloudflare Worker.