skip to content

For a team running an SPA and its API on Cloudflare Pages, how would you decide whether and when to move it to a Worker with static assets?

level: principalimportance: should knowfreq 30%

answer

  1. where the platform is investing
  2. features only one side has
  3. routing order flips
  4. domains outside Cloudflare's nameservers
  5. run both, then cut over

basics

~20 s

Cloudflare now points new projects to Workers with static assets, so new sites start there. An existing Pages app moves when it needs a Workers-only feature or a major rework, unless it relies on a domain outside Cloudflare's nameservers or Pages-only branch controls.

solid answer

~50 s

For new work the default is a Worker with static assets: Cloudflare's Pages docs say to start new projects with Workers, and costs match, with free static requests and Functions billed as Workers. For an existing Pages app I weigh **gains**: gradual deployments, Durable Objects without a separate Worker, Cron Triggers, Queue consumers, Workers Logs, Logpush, Tail Workers, serving on a path. Against them go **blockers**: Workers needs the domain's nameservers on Cloudflare, has less configurable branch deploy controls, and Pages' file routing must be compiled or replaced. Then **behaviour changes** to test: asset-first routing instead of Functions-first, explicit `not_found_handling`, navigation requests skipping code, separate build and runtime variables. I migrate when a feature or a rework justifies it, run the Worker in parallel on `workers.dev`, move the domain, and delete the Pages project last.

go deeper

for a junior

Know that Cloudflare now recommends Workers with static assets for new sites, and that static file requests are free on both Pages and Workers.

for a middle

Explain the concrete differences: asset-first routing, explicit not_found_handling, .assetsignore for files Pages skipped, and separate build and runtime variables.

for a senior

Plan the migration so it fails safely: inventory navigable server routes, run the Worker beside Pages, and keep the Pages project as rollback until traffic settles.

for a principal

Decide per project by triggers, not fashion: a Workers-only need or a rework moves it, a DNS blocker keeps it, and a stable site waits for its next major change.

## The question behind the question Cloudflare has two ways to host a site: **Pages**, with Git-driven builds, preview deployments and Pages Functions, and a **Worker with static assets**, where one Worker deployment carries a folder of files and an optional script. The Pages documentation now says plainly that Workers supports most Pages use cases, is Cloudflare's primary platform for applications, and that new projects should start with Workers. So for a new site the decision is mostly made. For an existing, working Pages app it is a real trade-off: migration costs engineering time and carries risk, while staying means missing features that only Workers has. ## What moving gains From Cloudflare's own comparison of the two, Workers supports and Pages does not: - **Gradual deployments** of new versions by percentage, beside rollbacks and preview URLs that both have. - **Cron Triggers**, **Queue consumers**, the **rate limiting** binding and Email Workers. - **Durable Objects** bound directly; on Pages they need a separate Worker bound in each environment. - **Observability**: Workers Logs, Logpush, Tail Workers and source maps; of these logging tools, Pages has only real-time logs. - **Serving on a path** of a domain through a route, such as `example.com/app/*`. - `wrangler dev --remote` against real remote resources during local development. Cost is roughly neutral: static asset requests are free on both, and Pages Functions are billed at Workers rates. The one shift is that Pages middleware becomes `run_worker_first`, whose matched requests are ordinary billed invocations. ## What blocks or slows it - **Domains.** Pages can serve a custom domain whose DNS lives elsewhere through a CNAME; a Worker's custom domain needs the zone's nameservers on Cloudflare. A team that cannot move DNS cannot fully migrate. - **Branch deploy controls** in Workers Builds are less configurable than in Pages. - **File-based routing** in a `functions/` folder and Pages Plugins have no direct equivalent: compile with `wrangler pages functions build`, or move to a web framework with its own routing. - **Early Hints** need the zone setting and `Link` headers sent by the Worker. ## What behaves differently These are the bugs a migration produces when nobody plans for them: | Area | Pages | Worker with static assets | | --- | --- | --- | | Routing order | Functions ran before assets | assets first unless `run_worker_first` | | SPA or 404 fallback | inferred from `index.html` and `404.html` | explicit `not_found_handling` | | Navigations that miss | reached Functions | served the fallback without code, compatibility date from 2025-04-01 | | Excluded files | `node_modules`, `.git`, `.DS_Store` skipped | uploaded unless in `.assetsignore` | | Variables | build and runtime shared | separate sets for builds and the runtime | | Default subdomain | `pages.dev` | `workers.dev` | ## How I would decide 1. **New site**: Workers with static assets, no debate needed. 2. **Existing app with a blocker** such as DNS that must stay elsewhere: stay on Pages and record the trigger that would reopen the question. 3. **Existing app that needs a Workers-only feature**, or is about to be reworked anyway: migrate now, because the work is cheapest when the code is already open. 4. **Stable app with no new needs**: leave it, and migrate at the next major change. A working site gains little from moving for its own sake. ## How to roll it out 1. Create the Wrangler config: `name`, `compatibility_date` copied from the Pages project, `assets.directory` replacing the build output directory, and `not_found_handling` set explicitly. 2. List every server route a browser navigates to, such as auth callbacks, in `run_worker_first`, and move middleware logic there. 3. Deploy beside the Pages project and test on the `workers.dev` URL or a preview URL, with the same bindings pointed at test resources. 4. Move the custom domain to the Worker, watch error rates and logs, and keep the Pages project as the rollback until traffic is settled. 5. Delete the Pages project with `wrangler pages project delete` once nothing depends on it. Ownership matters as much as the steps: one person owns the route inventory and the cutover, because the failures are subtle routing differences rather than build errors. Write the decision down per project, with the trigger that would change it, so that a later team does not re-argue a migration that was deliberately deferred or rush one that was blocked by DNS.

  • What would make you keep a Pages project instead of migrating?
    A hard blocker or no benefit. The hard blocker is a custom domain whose nameservers cannot move to Cloudflare, since Workers custom domains need them. No benefit means a stable site that needs no Workers-only feature and has no rework planned; moving it buys risk without return. I record the trigger that would reopen the decision rather than a date.
  • How do you keep a rollback during the cutover?
    Run the Worker beside the untouched Pages project and test it on its `workers.dev` or preview URL first. Move the custom domain only after that, and leave the Pages project deployed until traffic and error rates have settled, so the domain can be pointed back. Inside Workers, later releases can then use gradual deployments and rollbacks.
  • Does moving change what the team pays?
    Mostly not. Static asset requests are free on both, and Pages Functions are already billed as Workers requests. The difference to watch is middleware: on Workers it becomes `run_worker_first`, and every request it matches is a billed invocation, so a broad pattern or `true` can raise the bill.

  • Pages is still Cloudflare's recommended starting point for a new static site
  • Moving to Workers doubles the bill because every static file becomes a Worker request
  • A Worker can serve a custom domain whose nameservers stay with another DNS provider
  • Pages Functions folders deploy unchanged on Workers, with the same file-based routing
  • Every Pages project should be migrated at once, whatever its state

Reflects Cloudflare's platform as of 2026-10-10, when the Pages documentation directs new projects to Workers with static assets and its comparison table lists the differences used here.