Workers provide programmable edge compute. Pages Functions integrate Workers directly into your Pages site for APIs, SSR, and middleware.
Chip Architect Note: Treat Worker scripts like firmware hot paths: minimize bundle size, avoid megabyte-scale dependencies, prefer streaming and incremental parsing over whole-buffer operations.
Runtime model
- Fetch API-compatible environment.
- Request lifecycle per event; isolate, no cold VM boot.
- Bind services via environment: KV, D1, R2, Queues, secrets.
In this repo
/functions/api/time.js: returns current time JSON./functions/hello/[name].js: dynamic greeting route./functions/_middleware.js: addsx-request-id.