Cloudflare Pages vs Workers: which should you choose?

By

Updated

Tagged: Cloudflare

Compare Cloudflare Pages and Workers for static sites and full-stack apps, with request diagrams, pricing examples, and advice on when to migrate.

Both Cloudflare Pages and Cloudflare Workers can host a website, serve static files, and run server code. That makes picking between them a bit confusing when you’re starting out.

If you’re starting a new project, go with Workers. That holds whether you’re building a plain static blog, a React app, or an app backed by a database. Cloudflare now steers new projects toward Workers Static Assets and puts new feature work there, as they spell out in Cloudflare’s guidance.

If you already have a Pages site that works fine, leave it alone unless a migration solves a real problem for you. This blog runs on Pages and it keeps working without issues. Spending a weekend moving a healthy site just to match the new default is usually wasted effort.

The old rule of thumb, “Pages for websites, Workers for APIs,” is out of date now. Workers has grown to handle both, and once you see how the two compare, the choice gets much easier.

What Pages and Workers do

Cloudflare Pages is built around a Git deployment workflow. You connect a repository, set a build command and an output folder, and Cloudflare publishes the site with preview URLs and a production domain. When you need server-side routes, you add Pages Functions, which run on the Workers runtime and can handle form submissions, query a database, or render dynamic HTML.

Cloudflare Workers started as a place to run JavaScript handlers for events like HTTP requests. With Workers Static Assets, a Worker deployment can also include your HTML, CSS, browser JavaScript, and images. You can even deploy a folder of static files with no Worker script at all, as covered in the static assets documentation.

Picture a small recipe website with a home page, individual recipe pages, a stylesheet, and client-side search. Either Pages or Workers can host it. Even if you later add a private recipe collection that needs server code, both handle that too. What changes is how you configure the project and how far you can grow it inside a single deployment.

What you needPagesWorkers
Serve generated HTML, CSS, JS, and imagesYesYes, using Static Assets
Add HTTP endpointsPages FunctionsA Worker fetch handler or framework routes
Build after a Git pushPages Git integrationWorkers Builds
Preview changes before productionYesYes
Read D1, KV, or R2 from server codeSupported bindingsSupported bindings
Run a scheduled handlerUse a separate WorkerConfigure a Cron Trigger
Host a Durable Object implementationUse a separate Worker and bind to itDefine it in a Worker

Pages still supports bindings to Cloudflare services, including Durable Objects that live in another Worker. So you can wire up a database on Pages and keep running right where you are.

A decision chart for your project

Start by asking whether you already have a site deployed and working. Here’s the decision flow:

Choosing Cloudflare Pages or WorkersFor a new project, start with Workers. For an existing Pages project, keep it unless a requirement or recurring problem justifies migration.NoYesNoYesYesNoChoosing adeploymentAlready on Pages?Start with WorkersMissing a feature orfighting deploymentproblems?Keep PagesCan a small separateWorker solve it?Compare thataddition withmigrationTest a Workersmigration

If your team relies on a deployment integration that specifically expects Pages, verify that tooling first and stick with Pages if it’s required. Everyone else starting fresh is better off on Workers, where setup is straightforward and you have room to add server features whenever you need them.

Static sites on Workers don’t need server code

A static site is just a folder of files built ahead of time. Astro can read your Markdown files, pull data from a CMS, and generate thousands of HTML recipe pages during the build. Once that build finishes, Cloudflare only has to serve the finished files.

If your site builds into a dist folder, here’s all you need in wrangler.jsonc to deploy it on Workers:

{
  "name": "recipe-site",
  "compatibility_date": "2026-10-20",
  "assets": {
    "directory": "./dist",
    "not_found_handling": "404-page"
  }
}

Use today’s date for the compatibility date when you create the project, since it pins the runtime behavior rather than acting as a publish date.

Notice there’s no main field because there’s no server script. And if your site includes a 404.html page, 404-page tells Cloudflare to serve it when someone hits a missing URL.

Once your build finishes, deploy the folder with Wrangler:

npm run build
npx wrangler deploy

That assumes you already have a build script and Wrangler installed in the project. If you’re setting things up from scratch, follow the Workers Static Assets guide.

Putting a site on Workers lets Cloudflare serve matching static files directly, without running server code on every visit.

What happens when a request arrives?

Suppose your recipe site grows an API at /api/recipes. By default, when a Worker includes static assets, Cloudflare checks for a matching file first and serves it directly. Your Worker script only runs when no static asset matches the URL.

Step through this diagram to see where code runs for a static file, an API route, and a protected route:

Fig 1 · 1/4Which requests run your code?
A matching public file is served directly

Under the default routing, a request for /style.css returns the file right away, while /api/recipes falls through to your Worker code (as long as you don’t have a static file at that path).

You can flip that order when you need to check a user’s session before serving a private HTML file. Workers lets you set assets.run_worker_first to specific path patterns so your code runs before the asset layer, as explained in the Worker routing documentation.

Keep the security side of this in mind. An authorization check in your Worker only protects requests that reach your Worker. If you bundle private files as public static assets under the default asset-first routing, Cloudflare will serve them straight to anyone who knows the URL without ever calling your auth code.

Keep private recipe data behind an authenticated server endpoint instead. If you do need to protect specific files, configure assets.run_worker_first for those paths and test a logged-out request straight to the file URL, because anyone who guesses or shares that link can request it directly.

Pages handles routing in its own way. Pages Functions live in a functions/ directory, and a _routes.json file decides which requests hit them. Your framework or build tooling often generates _routes.json for you, so inspect the generated file, especially if you use middleware that matches broad paths. The Pages routing guide covers the exact invocation rules.

Before assuming how either setup behaves, trace a real request in production or preview to verify whether static files like images bypass your server code or trigger it.

A browser app can still use static hosting

A React or Vue app can render a full dashboard, switch views, filter data, and manage state entirely in the browser. If your build outputs browser files and fetches data from an external API, you can ship it as static assets with no server-rendering layer at all.

Single-page applications just need one extra rule for direct URLs. If someone opens /recipes/saved directly or refreshes the page, Cloudflare needs to return your app’s entry HTML even though there’s no static file at that path.

Workers handles this with not_found_handling: 'single-page-application'. Unlike the 404-page setting from earlier, unknown browser navigations load your app so your client-side router can take over. You can check the full setup in the SPA routing guide.

If that same Worker also serves an API, test three things before you ship: loading a nested app route directly in the browser, calling a real API endpoint, and calling a missing API endpoint. Getting your home page HTML back with a 200 status on a missing API route will break API clients in frustrating ways.

When Workers makes a bigger difference

Workers really pulls ahead once your app needs to do more than answer page requests.

Say your recipe app starts emailing a weekly meal plan on a schedule. In a Workers project, you add a scheduled handler backed by Cron Triggers. Later, you add photo uploads and want to resize images in the background without making the user wait, so you push jobs onto a Queue and process them in a consumer. If you eventually add a live shared cooking session where participants need to stay in sync, you can define a Durable Object right alongside the rest of your code.

Workers supports handlers for different event types inside the same project, and you only add them as you need them. Here’s how a Worker wires up multiple event handlers:

HTTP requests and background events in a Workers applicationBrowser requests reach an HTTP handler, a timer invokes a scheduled handler, and queued jobs reach a queue handler. Each performs a different part of the recipe application.Browser requestHTTP handlerWeekly timerScheduled handlerQueued image jobQueue handlerReturn a page or APIresponsePrepare the weeklymeal planProcess the uploadedimage

You can still keep an existing Pages frontend and have it call a separate Worker for background jobs, which makes sense when your frontend and backend ship on different schedules. For a small new app, though, keep the frontend and HTTP server together in one deployment and only split things out when team ownership, scaling, or maintenance gives you a concrete reason to.

Databases and authentication

Both Pages Functions and Workers can talk to D1, KV, and R2 through bindings. If you already run PostgreSQL or MySQL somewhere else, you can connect to it with a Hyperdrive binding on either platform.

That means needing a database won’t settle the Pages vs. Workers question on its own. A mostly static Pages site can query D1 from a Function, and a Workers app does the same thing from its server code. Either way, the browser calls your server endpoint, your code queries the binding, and you send back only what the user is allowed to see.

Authentication works the same way. Whichever platform you pick, your server code still has to validate the session and check permissions before returning private data.

How you render pages is a separate decision from where you host them. You can prerender public recipe pages at build time and render a user’s saved recipes on demand, all inside the same app.

Which should you use with Astro or another framework?

Look at what your framework outputs after a build.

If you’re building a static Astro site, the build gives you a plain folder of files that you can host on either Pages or Workers. You don’t even need the Cloudflare server adapter when you’re only serving generated HTML.

Once you turn on server-side rendering, you need an adapter built for your target platform. Follow the current Workers guide rather than dusting off an older Pages tutorial and swapping the deploy command. Cloudflare’s Astro deployment guide walks through static output, full server rendering, and mixing prerendered pages with on-demand routes.

The same distinction applies to any other framework you use. A static export is just files, while a full-stack build relies on generated routing, bindings, and a server entry point wired to the platform.

If you want to learn how these pieces fit together from the ground up, check out the free Cloudflare Handbook for the runtime and deployment side, and the free Astro Handbook for the framework side.

Git deployments, previews, and debugging

Pages makes deploys effortless because a Git push builds and ships your site. Workers can do the exact same thing through Workers Builds.

You can hook up a repository, set your build and deploy commands, and let Cloudflare handle the rest. Or you can run the build in your own CI and push with Wrangler. Either way, you get Git-driven deploys without building your own deployment pipeline.

Both platforms give you preview URLs for changes. Just keep in mind what you’re testing: checking a UI tweak on a branch is very different from testing a database migration or a webhook against isolated data.

Before you test anything destructive on a preview URL, check its bindings and secrets so you know which database it talks to. I dig into how preview environments work in my Worker Previews guide.

Once your app has real server logic, debugging tools start to matter a lot more. Pages gives you real-time logs, while Workers adds persisted Workers Logs and deeper observability. Cloudflare keeps an up-to-date feature comparison in its migration guide.

If a production bug happens overnight and vanishes before you can reproduce it, retained logs are a very practical reason to run on Workers. You can see how to inspect those requests in my Workers observability guide.

How the costs compare

For regular static files, both Pages and Workers give you free, unlimited static asset requests. On Workers, static files can go straight to the browser without invoking your Worker script (see Workers asset billing).

Here’s a sample traffic split to show how that plays out. The bars count requests that run your code rather than estimating a monthly bill.

Fig 2 · 1/3The same 1,000 requests, different compute usage
1,000 static requests; zero script invocations

In the mixed setup, 900 requests fetch static files directly and 100 run your code. Change the config so every request passes through middleware first, and all 1,000 requests invoke your code, even when the final response is a static file.

Sometimes you need that, like when you’re checking authentication or transforming a response. The real question is which paths need to run code and which ones can stay static.

Here’s what counts toward your limits and your bill:

UsageWhat to account for
Direct static asset deliveryFree, unlimited requests on both products
Workers and Pages Functions on FreeShared allowance of 100,000 dynamic requests per day, with a 10 ms CPU limit per invocation
Workers PaidStarts at $5 per account per month, with included request and CPU usage; extra usage is billed
D1, R2, and other attached servicesSeparate allowances and usage charges
Cloudflare-hosted buildsSeparate build limits from site requests

One detail that trips people up: Pages Functions count toward your Workers usage, so hosting the frontend on Pages still draws from that same shared free compute allowance. Check both the Pages Functions pricing and Workers pricing pages before estimating costs.

Also watch out if you enable the separate Workers Caching feature. Cache-served requests carry request charges, including static assets, so the free direct-asset numbers above apply when that feature is off.

Builds are metered differently too. Pages Free gives you 500 builds a month, while Workers Builds Free gives you 3,000 build minutes a month. Because one counts builds and the other counts time, a two-minute build and a fifteen-minute build burn through your Workers Builds quota at very different rates. Check the Pages limits and Workers Builds limits for your plan, along with the deployment, file-size, and server runtime limits for the files and jobs your project produces.

Should you migrate an existing Pages site?

Before touching anything, write down why you want to move.

“We need a queue consumer and want one application deployment” is a solid reason. So is “our framework’s current adapter targets Workers.” If you have a static site with a reliable deploy pipeline, you probably won’t gain much from migrating it right now.

This site is a good example of why you have to judge the whole app. Its generated articles run well on Pages, and it already has Functions and bindings wired up. Moving it means checking all of those routes and integrations, well beyond uploading the same HTML somewhere else.

For a plain static site, the move is small. Point a Workers project’s assets.directory at your build output, configure how missing pages behave, and test it before moving your domain.

If your project uses Functions, follow Cloudflare’s Pages-to-Workers migration guide. Workers expects explicit routing rather than auto-wiring a functions/ folder, so you’ll need to adapt or compile those file-based Functions. Framework-generated builds need their framework’s own migration instructions.

Before you switch traffic over, test these paths yourself:

  • A generated page, a CSS file, and an image.
  • A direct visit to a nested route and a missing URL.
  • A redirect and a response that needs custom headers.
  • A public API route and a private route while logged out.
  • A form submission, including its error response.
  • Preview bindings, production bindings, and required secrets.

Pay extra attention to redirects and custom headers. Static _headers rules apply to static assets, while responses returned by your server code need their headers set in code, so inspect the real responses from both paths.

You’ll also want to keep any uploaded server bundle out of your public asset directory. For Pages advanced-mode _worker.js builds, move the script out or exclude it from assets:

Migrating a Pages site without switching production firstKeep Pages serving production while creating a separate Workers deployment. Test routes, bindings, and error responses, then switch the custom domain. Keep the old deployment available for rollback.NoYesPages continuesserving productionCreate WorkersdeploymentTest routes,bindings, and errorsChecks pass?Fix and test againSwitch custom domainVerify productionresponsesKeep old deploymentfor rollback

One last thing to check is your default deployment URL, since pages.dev and workers.dev are different hostnames. Switching your custom domain only updates that domain, so if anyone relies on old pages.dev preview or deployment links, handle those separately.

What I would choose

For a new blog, documentation site, or portfolio, deploy your generated files on Workers Static Assets and keep it completely static until a feature needs server code.

For a new app with accounts, saved data, or on-demand HTML, use Workers with your framework’s supported adapter. Keep static files on the direct asset path where possible so they skip your Worker script.

For this existing Pages blog, I’m keeping it on Pages until there’s a concrete reason to move. If it only needed a scheduled job, I’d compare adding one small standalone Worker against migrating the whole site.

Before you create your project, look at its build output and list the requests that need server code. That gives you your starting config right away, plus a short list of routes to verify once you deploy.

Want me to talk about your product? You can sponsor this site.

Related posts about cloudflare: