Deployment
Static pre-rendering, Cloudflare Workers static assets, headers, redirects and custom domains.
On this page
The site has no runtime server. react-router build pre-renders every route into build/client; Cloudflare Workers serves those files as static assets and only unknown URLs fall back to the generated 404.html.
Build#
The build output contains one HTML file per route plus React Router's .data files for client navigation. Do not flatten or rename these files.
Cloudflare Workers#
- 1
Create the Worker
In the Cloudflare dashboard, create a Worker under Workers & Pages and connect it to this repository.
- 2
Set build and deploy
Build command
npm run typecheck && npm test && npm run build, deploy commandnpx wrangler deploy, Node 22. - 3
Any domain works
No build variables: the origin of canonical, OG, JSON-LD and sitemap URLs is replaced at the edge with the request domain, so
*.workers.dev, preview URLs and custom domains all work as-is. - 4
Deploy
Push to main, or run
npm run deploywith Wrangler authenticated locally.
Headers and redirects#
| File | Purpose |
|---|---|
public/_headers | Security headers and immutable asset caching. |
404.html (generated) | Branded 404 response for unknown URLs; known routes are served from their own HTML files. |
public/robots.txt | Crawler policy and sitemap location. |
scripts/build-sitemap.mjs | Walks the pre-rendered HTML and writes sitemap.xml. |
Order matters
Cloudflare Workers static assets serve an existing file first. If a route 404s, check that its pre-rendered HTML exists before changing the 404 fallback.
Custom domain#
- Add the domain under Worker → Settings → Domains & Routes and follow the DNS instructions.
- Switching domains needs no reconfiguration: canonical and sitemap URLs follow the request domain.
- Submit the generated
sitemap.xmlin Search Console.