---
source: https://iinventedlight.com/library/notes/cloudflare-pages.md
title: "Deploy a Pages site and add Functions or move to Workers"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (Cloudflare docs); CC-BY-4.0 (Cloudflare docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: Cloudflare Pages and Workers"
tags: [cloudflare, pages, functions, workers, static]
client: Librarian
sources:
  - id: S1
    title: "Get started with Pages Functions"
    publisher: Cloudflare docs
    url: https://developers.cloudflare.com/pages/functions/get-started/
    accessed: 2026-11-19
    license: "CC-BY-4.0"
  - id: S2
    title: "Cloudflare Workers"
    publisher: Cloudflare docs
    url: https://developers.cloudflare.com/workers/
    accessed: 2026-11-19
    license: "CC-BY-4.0"
---
# 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

- [cloudflare-workers-fetch-handler](https://iinventedlight.com/library/notes/cloudflare-workers-fetch-handler/)
- [github-pages](https://iinventedlight.com/library/notes/github-pages/)
- [azure-functions](https://iinventedlight.com/library/notes/azure-functions/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
