Deploy a Pages site and add Functions or move to Workers
Answer: Writing Function files in the /functions directory automatically generates a Worker with custom functionality at predesignated routes. Cloudflare Workers is a serverless platform for building, deploying, and scaling apps across Cloudflare's global network.
Functions routing
A Pages project must already exist locally or on the dashboard. Create a /functions directory at the root of your Pages project, not in the static root, such as /dist. A helloworld.js file in that folder that exports onRequest runs on the /helloworld route. The handler is passed a request context object. Return a Response, or a Promise of a Response. Advanced mode lets you develop Pages Functions with a _worker.js file rather than the /functions directory.
Workers runtime and platform
Workers runtime features are configurable on Pages Functions. That includes compatibility with a subset of Node.js APIs. You can also set a compatibility date or a compatibility flag. Pass an argument to Wrangler to set those configurations. Workers itself can deploy static assets, build APIs, run cron jobs and Workflows, and connect to Durable Objects, KV, and R2 through bindings.
| /functions | Workers | |---|---| | /functions directory | File-based Functions that generate a Worker | | onRequest | Handler that must return a Response | | _worker.js | Advanced mode rather than /functions | | Workers | Serverless platform for building and deploying apps |
See also
Claims
- id: C1 claim: A /functions directory at the Pages project root generates a Worker from those files. source: S1 evidence: "create a /functions directory"
- id: C2 claim: The onRequest handler must return a Response or a Promise of a Response. source: S1 evidence: "must return a Response or a Promise"
- id: C3 claim: Workers is a serverless platform for building and deploying apps on Cloudflare's global network. source: S2 evidence: "A serverless platform for building, deploying, and scaling apps"
Sources
- [S1] Get started with Pages Functions. Cloudflare docs. https://developers.cloudflare.com/pages/functions/get-started/ . License: CC-BY-4.0. Accessed 2026-11-19.
- [S2] Cloudflare Workers. Cloudflare docs. https://developers.cloudflare.com/workers/ . License: CC-BY-4.0. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Cloudflare docs, Get started with Pages Functions; Cloudflare docs, Cloudflare Workers. CC-BY-4.0; CC-BY-4.0. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Cloudflare docs, Get started with Pages Functions; Cloudflare docs, Cloudflare Workers. CC-BY-4.0; CC-BY-4.0.
Cite this
iinventedlight. 2026. "Deploy a Pages site and add Functions or move to Workers." iinventedlight Library, iil:note:5bt2zpd6, version of 2026-11-19. https://iinventedlight.com/library/notes/cloudflare-pages/. License: CC-BY-4.0.
@misc{iil_note_5bt2zpd6,
author = {{iinventedlight}},
title = {{Deploy a Pages site and add Functions or move to Workers}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/cloudflare-pages/},
note = {Permanent ID iil:note:5bt2zpd6. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- cloudflare-pages.table.json (table; CC-BY-4.0)
- cloudflare-pages.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/cloudflare-pages.md.