Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/workers-for-platforms/README.md
1# Cloudflare Workers for Platforms23Multi-tenant platform with isolated customer code execution at scale.45## Use Cases67- Multi-tenant SaaS running customer code8- AI-generated code execution in secure sandboxes9- Programmable platforms with isolated compute10- Edge functions/serverless platforms11- Website builders with static + dynamic content12- Unlimited app deployment at scale1314**NOT for general Workers** - only for Workers for Platforms architecture.1516## Quick Start1718**One-click deploy:** [Platform Starter Kit](https://github.com/cloudflare/workers-for-platforms-example) deploys complete WfP setup with dispatch namespace, dispatch worker, and user worker example.1920[](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/workers-for-platforms-example)2122**Manual setup:** See [configuration.md](./configuration.md) for namespace creation and dispatch worker configuration.2324## Key Features2526- Unlimited Workers per namespace (no script limits)27- Automatic tenant isolation28- Custom CPU/subrequest limits per customer29- Hostname routing (subdomains/vanity domains)30- Egress/ingress control31- Static assets support32- Tags for bulk operations3334## Architecture3536**4 Components:**371. **Dispatch Namespace** - Container for unlimited customer Workers, automatic isolation (untrusted mode by default - no request.cf access, no shared cache)382. **Dynamic Dispatch Worker** - Entry point, routes requests, enforces platform logic (auth, limits, validation)393. **User Workers** - Customer code in isolated sandboxes, API-deployed, optional bindings (KV/D1/R2/DO)404. **Outbound Worker** (optional) - Intercepts external fetch, controls egress, logs subrequests (blocks TCP socket connect() API)4142**Request Flow:**43```44Request → Dispatch Worker → Determines user Worker → env.DISPATCHER.get("customer")45→ User Worker executes (Outbound Worker for external fetch) → Response → Dispatch Worker → Client46```4748## Decision Trees4950### When to Use Workers for Platforms51```52Need to run code?53├─ Your code only → Regular Workers54├─ Customer/AI code → Workers for Platforms55└─ Untrusted code in sandbox → Workers for Platforms OR Sandbox API56```5758### Routing Strategy Selection59```60Hostname routing needed?61├─ Subdomains only (*.saas.com) → `*.saas.com/*` route + subdomain extraction62├─ Custom domains → `*/*` wildcard + Cloudflare for SaaS + KV/metadata routing63└─ Path-based (/customer/app) → Any route + path parsing64```6566### Isolation Mode Selection67```68Worker mode?69├─ Running customer code → Untrusted (default)70├─ Need request.cf geolocation → Trusted mode71├─ Internal platform, controlled code → Trusted mode with cache key prefixes72└─ Maximum isolation → Untrusted + unique resources per customer73```7475## In This Reference7677| File | Purpose | When to Read |78|------|---------|--------------|79| [configuration.md](./configuration.md) | Namespace setup, dispatch worker config | First-time setup, changing limits |80| [api.md](./api.md) | User worker API, dispatch API, outbound worker | Deploying workers, SDK integration |81| [patterns.md](./patterns.md) | Multi-tenancy, routing, egress control | Planning architecture, scaling |82| [gotchas.md](./gotchas.md) | Limits, isolation issues, best practices | Debugging, production prep |8384## See Also85- [workers](../workers/) - Core Workers runtime documentation86- [durable-objects](../durable-objects/) - Stateful multi-tenant patterns87- [sandbox](../sandbox/) - Alternative for untrusted code execution88- [Reference Architecture: Programmable Platforms](https://developers.cloudflare.com/reference-architecture/diagrams/serverless/programmable-platforms/)89- [Reference Architecture: AI Vibe Coding Platform](https://developers.cloudflare.com/reference-architecture/diagrams/ai/ai-vibe-coding-platform/)90