For modern internet-facing apps, Cloudflare gives developers a focused, integrated set of primitives
that compose globally by default — full-stack apps, AI agents, APIs, and real-time systems,
all on the same network that already handles your security and delivery.
AI agentsStateful agents with tools, memory, scheduling, and Workers AI
Full-stack appsFrameworks, APIs, storage, auth, and deploys on one platform
Real-time systemsDurable Objects, WebSockets, coordination, and live shared state
Focused builder communityFast feedback loopBuilders inform the roadmap
More apps only helps if the runtime keeps up. Which parts of your stack are paying a global tax because they were built for a single region?
Runtime evolution · workerd · Node.js · Deno · V8
One runtime. Thousands of isolated apps.
Workers runs as V8 isolates across Cloudflare's global network. workerd — the open-source runtime behind Workers — lets one process host thousands of isolated apps with no per-app container to boot.
Why it matters
One process, many apps: workerd runs each Worker in its own V8 isolate inside a shared process. You get strong separation without starting a container for every app.
Global by default: code runs across 330+ Cloudflare PoPs, close to users — no region to pin.
Pay for what runs: no idle-instance cost. Billed on requests and CPU time consumed.
Security at the perimeter: auth, validation, and policy enforcement run where Cloudflare already processes traffic.
How a Worker runs
Your codeone fetch() handler: a request in, a response out
Web standard APIsfetch, Request / Response, Streams, Web Crypto
V8 isolateone per Worker · starts in milliseconds · no container
workerdthe open-source runtime (Apache 2.0), the same one wrangler dev runs on your laptop
Cloudflare networkdeploy once, it runs in 330+ cities
export default {
async fetch(request, env, ctx) {
// env = your bindings: KV, R2, D1, Durable Objects…
return new Response("Hola from Barcelona");
},
};
npx wrangler dev runs it locally on workerd · npx wrangler deploy sends it everywhere
Servers
One box, one app, operational ownership of OS, runtime, packages, and capacity.
↻
↻
↻
↻
VMs
Better isolation and scheduling, but each unit still carries a lot of runtime surface.
↻
↻
↻
↻
↻
↻
↻
↻
↻
Containers
Process-level isolation. Slow cold starts (500ms-10s). Heavy context switching overhead between customer workloads.
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
{}
↻
Workers isolates
Lightweight execution contexts inside a shared V8 runtime. One process can run thousands of isolates with minimal per-request overhead.
Lightweight compute is the start, not the whole platform. The real leverage appears when storage, AI, media, and orchestration are native bindings.
One Worker, many bindings
Bindings are your platform building blocks.
Most clouds wire services together with SDKs, roles, networks, gateways, and secrets. Workers use bindings instead: pre-authorized capability handles injected into env before your code runs.
Cloudflare WorkerWorkerenv.* injected
D1 · R2 · KV · Artifactsdata, files, and repos
Durable Objects · Service Bindingsstate and internal calls
Workers AI · Vectorize · AI Gatewaymodels and context
Images · Streammedia pipelines
Queues · Workflows · Emailbackground work
Analytics Enginemetrics and telemetry
No auth plumbingNo tokens to store, rotate, or leak.
No internet hopCalls resolve inside Cloudflare's network.
Runtime injectionNo SDK import just to access the resource.
Once the platform is available inside the Worker, the same model can host websites, APIs, tenant code, agents, storage-backed apps, and media workflows.
Full-stack web apps
Use the framework your team already knows.
Workers becomes the deployment target for modern web applications: server-rendered
routes, APIs, static assets, and edge logic all living close to users.
Production web frameworks
Next.jsAstroSvelteKitNuxtReact RouterTanStack StartAngularSolid StartViteVueHonovinextStatic sites+ And moreView all ↗
Use the language that fits
All paths share the same V8 isolate model and Bindings API
JS / TSNative V8Request handlers run directly in the Workers runtime — no separate server process, no translation layer.
JavaScriptTypeScript
PythonPyodide on V8CPython inside a V8 isolate via Pyodide. Deploy-time snapshotting cuts startup cost — no separate precompile step.
PyodideV8 isolatesSnapshotting
Adapters + WasmBring your stackLanguages that compile to Wasm run inside the isolate. Framework adapters map onto the Workers Request/Response model.
GoC / C++Next.jsSvelteKitNuxt
RustRust WorkersbetaWrite Workers in Rust with workers-rs, compiled to Wasm. Fuller Rust support is in beta.
Billed every 10ms while awake. CPU only when used; memory and disk by instance size.
Handling a request
CPU pay for use
Memory + disk pay
Awake, no requests
CPU ~$0 if nothing runs
Memory + disk pay
until the sleep timeout
Asleep
CPU $0
Memory + disk $0
scales to zero
CPU 375 vCPU-min/mo
Memory 25 GiB-h/mo
Disk 200 GB-h/mo
Egress 1 TB/mo NA & EU
Also billed: the Worker in front and each container's Durable Object. Tip: instance size sets the idle cost; the sleep timeout sets how long you pay it.
Images
Dockerfile built by wrangler deploy
Or push an existing image to the Cloudflare registry first
Bindings & ops
Access KV, D1, R2, Queues via hostname
Data residency: set jurisdiction on the Durable Object namespace (EU / US / FedRAMP).
SSH via Wrangler (needs ssh + authorized_keys in config)
Workers Paid plan
linux/amd64 images
Docker running locally to deploy
Durable-Object-controlled setup is public beta
First deploy: a few minutes to provision
Ship the same way you build
Deployment lifecycle — local workerd, branch Previews, production. Workers Builds or your own CI.
EXPAND ▾COLLAPSE ▴
Where things run
Tooling
Your laptop / CI runner · Node.js
C3WranglerVite
wrangler dev / wrangler preview / wrangler deploy
Your code
workerd · the Workers runtime
Miniflare (local)Cloudflare network (production)
Node.js runs the tools. Your Worker always runs on workerd.
Node.js + npm (Current, Active, or Maintenance releases) · macOS 13.5+, Windows 11, Linux glibc 2.35+
Scaffold, bind, and iterate locally. Then ship a branch Preview or production deploy.
Install the tooling
Wrangler and C3 are Node.js CLIs. Install Wrangler in your project and check its version.
Install + check
npm i -D wrangler@latest
npx wrangler --version
Start with C3
Create a Worker or framework app with C3 — Create Cloudflare CLI.
Create a project
npm create cloudflare@latest
Connect your resources
Add platform resources as bindings in wrangler.jsonc, then use them from env.
In your Worker
env.DB
env.AI
env.BUCKET
Iterate in local workerd
Miniflare runs your Worker in a local workerd process with simulated KV, D1, and more. For real Cloudflare resources, set "remote": true on a binding or use wrangler dev --remote. Vite gives frontend apps a fast dev loop with vite dev.
Local development
wrangler dev
One branch, one Preview
npx wrangler preview creates or updates a Preview for your current branch (name defaults to the branch) under the same Worker. Configure its variables, secrets, and bindings in the previews block of wrangler.jsonc — Previews don't inherit most production settings. Requires Wrangler 4.135.0+.
CLI equivalent
npx wrangler preview
Setup
Connect a repo in the dashboard — Artifacts, GitHub, or GitLab.
On push
Turn on Preview Builds and every push to a non-production branch creates or updates a Preview. GitHub and GitLab can post the Preview URL on the PR/MR.
Builds generates and uses an API token for you by default.
Add CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as CI secrets — CI is non-interactive, so no wrangler login.
wrangler.jsoncPer Worker: entrypoint, bindings, routes, variables, and the previews block.
Cloudflare Terraform providerAccount resources as code: Workers, KV, D1, R2, routes, and secrets — declarative and version-controlled.
Shipping is half the job. Once it's live, you need to see what it's doing.
Run it in production
See every request. Find what broke.
Workers Observability collects logs, traces and metrics for your Workers automatically — turn it on once, and every request, binding call and error shows up in the dashboard. No agents to install, no SDK to wire up.
Logs
Workers Logs
Best for: troubleshooting
Collected, stored logs you can filter and query. Query Builder adds filters, aggregations and group-bys to find the request that went wrong.
Request journey
Traces
Best for: “why is this slow?”
An end-to-end request view. Automatic instrumentation covers fetch calls, binding calls (KV, R2, Durable Objects), RPC and handlers — no code changes or SDK.
Recurring failures
Issues
Best for: on-call
Detects and groups recurring failures. Automations can send an issue to a coding agent, webhook, chat service or incident-management tool.
OpenTelemetry
Bring your stack
Best for: teams with existing tools
Export logs and traces through OpenTelemetry to supported destinations. Use Logpush or Tail Workers for custom pipelines.
Observability is a platform feature, not a binding. Logs and traces have separate settings; enable traces in the dashboard when you need the request journey. The live demo below has logs enabled, not traces.
Now you can see what your code is doing. The data it reads and writes still needs a home: keys, rows, files, vectors, metrics, or the database you already run.
Storage
Pick the storage shape that fits the workload.
Each storage primitive is a Worker binding: declare it once, use it from env — no API keys, no connection plumbing. Pick the shape that matches your data.
Key/value
KV
Best for: config, flags, sessions, cached data
Globally replicated reads close to users. Eventually consistent — great for reads, not for counters or carts.
env.KV.get(key)
SQLEU · US
D1
Best for: relational app data
Serverless SQLite with transactions, migrations, backups, and read replicas — no database server to run.
Best for: code, agent sessions, versioned file trees
Git-compatible repos at scale — fork, diff, and hand off to any Git tool.
env.ARTIFACTS.create("agent-007")
Vector DB
Vectorize
Best for: semantic search, RAG context
Vector indexes for embeddings, retrieval, and recommendations.
env.VECTOR_INDEX.query(embedding)
Bring your DB
Hyperdrive
Best for: your existing Postgres/MySQL
Keep your database, gain edge speed — warm pooled connections and query caching, no migration.
env.HYPERDRIVE.connectionString
Per-key stateEU · US
Durable Objects
Best for: live shared state per user, room, or tenant
One named object per key, with its own code, storage, and connections.
env.ROOMS.get(id)
Not sure which?
What are you storing?
Click again or press Esc to reset.
Pin data to a jurisdiction — D1, R2, Durable Objects, and Artifacts support EU and US. Data localization docs ↗
Analytics Engine: write an event, read with SQL
Your own usage metrics, not Worker logs or AI Gateway analytics.
EXPAND ▾COLLAPSE ▴
Why it's different
Sampling by design, not as a last resort.
Per-user or per-tenant metrics make most time-series databases slow or expensive. Analytics Engine samples by design: unbounded cardinality at a low, predictable price.
100% storedBig tenants fine. Small tenants vanish.Very similar picture, <10% of the data stored.
How it works
Write time
Sampling is per index value: busy ones are sampled harder, rare ones may keep every point. Pick the index you'll query by (tenant ID, hostname).
Read time
Data is kept at several resolutions (e.g. 100% / 10% / 1%). Longer time ranges read a coarser one, so every query fits a fixed query budget. That's why you weight by _sample_interval ↓
Great for
Per-tenant usage & cost attribution
Feature adoption by segment
High-cardinality performance metrics
Not for
Exact counts or billing (use D1 / Durable Objects)
// Write: one data point per request
env.METRICS.writeDataPoint({
indexes: [tenantId], // 1 index, used for sampling
blobs: [route, country, model], // up to 20 text dimensions
doubles: [latencyMs, tokens], // up to 20 numbers
});
Read with SQL
SELECT blob1 AS route,
SUM(_sample_interval) AS requests,
SUM(_sample_interval * double1) / SUM(_sample_interval) AS avg_ms
FROM metrics
WHERE timestamp > NOW() - INTERVAL '1' HOUR
GROUP BY route ORDER BY requests DESC
Read with SQL: the SQL API, Grafana, or the Analytics SQL binding (beta). The query weights sampled data with _sample_interval.
Data is retained for 3 months. Workers Paid includes 10M points written and 1M read queries per month. Usage is currently not billed ↗.
Your code runs in 330+ cities. Your database lives in one. So what happens when users around the world need to read and write the same state — the same room, cart, or document?
Stateful compute
Stateless by design. Stateful by name.
A Worker runs everywhere — thousands of copies, no shared memory — so two requests can't reliably coordinate through it. A Durable Object is the shared place they meet: an instance of a JavaScript class you write, reached by name, with at most one live instance worldwide, single-threaded, and its own private SQLite.
But there's a catch… ▾
Stateless Workers in 330+ cities · your database in one region
✗ = no database next to each Worker: you can't run one (and keep it in sync) in 330+ cities
Hyperdrive keeps those connections warm for an existing database (see Storage). For state that belongs to one room, user, or document, a Durable Object puts the database inside.
All traffic for one name → one Durable Object
① One nameevery Worker reaches the same object via getByName()
② JS event loopsingle-threaded; input gates stop concurrent requests from racing
③ SQLitelives inside the object — storage calls skip the network
④ WebSockets · ⑤ Alarmsalso built in, below
Scale by adding objects, not by growing one — one per room, user, or tenant. Need one shared relational database instead? That's D1.
What named state unlocks
WebSockets + HibernationCloudflare holds the connection; your code hibernates between messages. Create as many objects as you want — idle, hibernated objects accrue no duration charges. Up to 32,768 connections per object.
Incoming messages bill as requests at 20:1; storage is billed separately.
Durable Object StoragePrivate SQLite: SQL, KV, transactions, PITR. Each object is created on first access, has a soft limit of ~1,000 req/s, and gets up to 10 GB on Workers Paid (1 GB on Free) — about 20M chat messages at ~500 bytes each.
SQLKVtransactionsPITR
Alarms
Alarms wake a room later without keeping it alive: expire sessions, flush batches, run cleanup, or schedule the next task.
Retention alarms delete/archive old messages.
scheduled wakecleanupretention alarm
LESSONS FROM PRODUCTION
Cost, durability and location: what we learned running Durable Objects.
EXPAND ▾COLLAPSE ▴
Asleep isn't free
ACTIVEcompute + storage
HIBERNATINGstorage only
deleteAll()$0
Idle objects that can hibernate aren't billed for compute time. Stored data still is: $0.20/GB-month beyond the 5 GB-month included on Workers Paid.
Storage bills until you delete it. deleteAll() is the only way to bring an object to zero, including the small internal metadata every write leaves.
Tip: when an event or session ends, archive to R2 (about 13× cheaper per GB-month), then call deleteAll().
Always survivesSQLite data. A write is confirmed only once it's safely stored.
Survives sleep, not restartsHibernated WebSockets and their attachments stay connected while the object sleeps. Deploys and restarts drop them, so clients should reconnect.
Always lostEverything else in memory: variables, caches, open fetches.
FIBERS (AGENTS SDK)
Fibers are an Agents SDK feature built on SQLite and alarms; plain Durable Objects don't have them. A fiber keeps the object awake while long work runs and saves checkpoints you choose. After a restart, onFiberRecovered() gives your code the last checkpoint; your code does the resuming. It doesn't save all of memory. Trade-off: the object stays awake on purpose, so you pay for compute while the fiber runs. That's the opposite of hibernation. Frameworks build on this too: Flue uses fibers to recover interrupted agent work, and replays only when it's provably safe.
Created near its first request. Then it stays there.
LOCATION HINT (e.g. weur)
Best effort, and only applies to the first get().
JURISDICTION (eu · us · fedramp)
Restricts where the object runs and stores data to that region.
(object IDs are still logged outside for billing/debugging)
You choose a region, not a specific city or data center.
DO OBJECTS MOVE CLOSER TO USERS?
Not today. Objects don't change location after they're created; relocation is planned. This applies to Agents too, since each agent is a Durable Object. Smart Placement runs ordinary Workers closer to your backend, not toward users. To move an object, create a new one in the new place and copy the data.
Each object is created close to its first request. Users elsewhere reach it over Cloudflare's network — over WebSockets that's one extra network trip per message, fine for chat and collaboration.
One object per room, document, user or match, so each is created near its users.
Pass a location hint when creating objects ahead of time.
PATTERN: hub + regional shards. The hub keeps the single message order; nearby shards hold the connections.
Design pattern · not a product feature
Hubsingle message order
Regional shardconnections
Regional shardconnections
Regional shardconnections
Serve read-heavy data from KV, the cache or D1 read replicas (public beta).
The real limit: one global piece of state that's written constantly and is very latency-sensitive.
Counting things globally (page views, API calls, tokens)? Don't send every write through one Durable Object — write data points to Analytics Engine instead.
With state and storage available as bindings, code can become more than a request handler. Agents add memory, tools, and safe boundaries on top.
Agents that scale
Build, Govern & Secure Agents
Every agent is a Durable Object: a unique name, one request at a time, storage that survives hibernation. Agents SDK wraps that into a typed agent class. Sandbox (Linux container) and Browser Run extend the tool surface without widening your Worker's trust boundary.
A Worker handles the event. A Durable Object gives the agent identity. Capabilities stay behind explicit boundaries.
Runtime
Events execute in V8 isolates. Events arrive via fetch(), WebSocket, MCP, or schedule. Services injected as env.* — no shared state.
Identity + State
One Durable Object per session. Same address, same memory, every call.
Capabilities
AI Gateway · Workers AI · Sandbox SDK · Browser Run · Dynamic Workers — each behind an explicit dispatch boundary. Tool code runs outside the agent’s own execution boundary.
Workspace per session
Give each agent session its own Artifacts repo or branch — fork from a shared baseline, explore in parallel, compare or merge the results.
Agents SDK
Durable identity, persistent state, real-time connections, scheduled work
EXPAND ▾COLLAPSE ▴
ANATOMY OF AN AGENT
From pull to push: agents don't wait to be asked.
Every agent on Cloudflare is a Durable Object with a durable identity, its own SQL storage, real-time connections, scheduled work and recoverable execution. Here's what's inside. Agents SDK docs →
Follow one request: event → wake → think → act. Click any part to open it.
Channels
FROM PULL TO PUSH · REACTIVE → PROACTIVE
Traditional apps wait for a user to ask. An agent can be woken by an email, a Slack message, a webhook or its own schedule, and act on its own.
PULL (reactive)
Userstarts it
asksanswers
Appwaits to be asked
PUSH (proactive)
Email / Webhook / Schedulestarts it
wakes
Agentacts on its own
notifies
Userdidn't have to ask
Chat, voice, email, Slack and webhooks all reach the same durable agent.
Webhook arrives
Agent wakes
Acts
Hibernatesidle WebSocket connections stay open without using compute
Capabilitiesinstalled per objectWebSockets · State Scheduler · MCP connections
↓ handle
Your codeonRequest() onStart()
Harnessoptionalagent loop model calls · tools
persist / schedule
SQLitestate · jobscheckpointssessions when installed
↓ jobs set alarm
Single alarmLifecycle owns it
wake
model / tool calls
response / stream
Client → Worker routing → named Durable Object → Lifecycle → installed capabilities, your code or an optional harness. Handlers return a response/stream via the Worker, call external services, or save progress in SQLite. Durable jobs set the single alarm; when it fires, it wakes Lifecycle.
The Agent class is a preset of this runtime: it installs Lifecycle and several capabilities for you. A harness is optional and supplies the agent loop.
When work needs to outlive a turn
Choose an execution pattern
Fibers — recover work inside the agent
runFiber() keeps the object alive during execution and stores recovery metadata. stash() saves checkpoints. After eviction, onFiberRecovered() decides how to continue.
runFiber()stash() · checkpoint 1, then 2
Restartoriginal closure is gone
onFiberRecovered()reads snapshot · your recovery
The original function isn't replayed automatically. Recovery logic belongs to your application.
Reference details · billing, concurrency and recovery
Durable execution: write the steps, Cloudflare keeps them running.
Hand off independent work that needs per-step retries, waits, approvals, and progress reporting.
Retries belong to each step.do; make external side effects retry-safe in your application.
Workers and Workflows bill CPU time, not wall-clockWaiting uses no CPU time; requests, steps and storage bill separately. Pricing ↗
50,000 concurrent instances per account on Workers PaidSleeping / waiting instances are excluded; step.waitForEvent waits for external decisions. Limits ↗
Workflow retry defaults are per step.do: 5 retries, 10,000 ms delay, exponential backoff and a 10-minute timeout. Retry settings ↗
For fibers, startFiber() starts tracked background work on the Agent class; recovery still belongs in onFiberRecovered().
A harness turns a model into an agent. It builds each turn’s prompt and context, calls the model, coordinates tools, handles results, streams output, and decides whether to continue or stop.
ModelGenerates reasoning, text, and tool requests.
HarnessOwns agent behavior and the model/tool loop.
Cloudflare adapterConnects the harness to storage, Lifecycle, and recovery.
RecoveryAutomatically resumesResumes with caveatsNo automatic recovery provided by the example runnerYou implement it
Tools
Think of MCP as a universal port for AI tools: one standard for any server's tools, resources and prompts.
For protected servers, the agent returns an authorization link; the user approves with the provider and the connection completes, with OAuth state kept in the agent's Durable Object.
authUrl returned
user approves
ready
MCP server portals · Cloudflare One
MCP clientsyour agent
Portalone /mcp endpoint
✓Accesswho · device · which tools
logs every tool call
SaaS MCP servers
Internal serversprivate, via Tunnel
One endpoint for approved MCP servers; Gateway routing adds HTTP logging and DLP.
Curate tools per portalGateway DLP scanningService tokens for agents
MCP doesn't replace Code Mode: Code Mode can wrap MCP servers and OpenAPI specs alike.
No tool for that? Let the agent write one.
Custom tools on the fly: the agent generates a tool to call an integration or automate a step, runs it once in a fresh Dynamic Worker — an isolated Worker for AI-written JavaScript — and throws it away.
Scroll the diagram sideways →
Code Mode: instead of hundreds of tool definitions, give the agent a typed API and let it write and run code against it. Data is processed programmatically instead of being pushed through the LLM — Cloudflare cites up to 80% savings in inference tokens and cost. Code Mode example →
Bindings you chooseGenerated code gets only the env you pass in — never your API keys.
Outbound controlBlock or intercept fetch() with globalOutbound.
Run limitsCap CPU time and subrequests per run.
Per-run logsTail Workers capture every execution.
Durable Object Facets give dynamic code its own isolated SQLite storage.
Headless Chrome on Cloudflare's network — screenshots, PDFs, structured data
Scroll the diagram sideways →
Browser Run provides headless Chrome via a Worker binding. Use quickAction() for instant captures or full Puppeteer/Playwright/CDP/Stagehand sessions. Live View and session recording are available for human-in-the-loop workflows.
WHEN THE DOM ISN'T READABLE
Some sites render into a canvas or ship obfuscated, ever-changing markup, so fetching the HTML gives an agent nothing useful. Browser Run loads and fully renders the page like a real visitor. When there's no clean DOM to read, take a screenshot and hand it to an image-capable model.
AI Security for Apps ↗ (formerly Firewall for AI) · WAF prompt-injection / PII checks for configured incoming cf-llm JSON endpoints; subject to plan and setup.
Detection is one layer—not a substitute for permissions and approval.
Record the decision
Who requested→what was approved→what ran→outcome
MCP elicitation collects missing input; it is not authorization.
Agents can pay for APIs and content per request, with no account signup or pre-shared API key. Supported protocols: x402 and Machine Payments Protocol (MPP), both built on HTTP 402.
Agent requests
402 + payment challenge
Agent pays & retries
200 + receipt
x402 uses stablecoins. MPP also supports cards via Stripe and works with existing x402 services. With x402, agents can optionally ask a human before paying. You can also charge agents: gate HTTP routes or MCP tools.
Prefer a framework? Write one function, get a durable agent.
EXPAND ▾COLLAPSE ▴
Flue is an open-source TypeScript framework from the Astro team, now at Cloudflare: you write one function, it provides the Pi agent loop and a durable runtime.
Your agent function
'use agent';
import { useModel, useTool } from '@flue/runtime';
export function SupportAgent() {
useModel('anthropic/claude-sonnet-4-6');
useTool(searchDocs);
return 'Answer customers using the docs.';
}
vite build && wrangler deploy Or use Workers AI models with no API keys.
Mount explicitly in app.ts:createAgentRouter(SupportAgent)at /agents/support, then call POST /agents/support/:id
Where it lives · on CloudflareYour function inside Flue, inside the Cloudflare runtimeNested boundaries, from outside in: Worker handles routing and bindings. Each agent is a Durable Object with SQLite and alarms; the use agent directive produces the Durable Object class. Agents SDK provides fibers, scheduling and state. Highlighted Flue provides the Pi agent loop, sessions, recovery and channels. Your function sits inside Flue and uses hooks such as useModel and useTool. These are layers, not a traffic flow.WorkerDurable ObjectAgents SDKFluerouting · bindingsone per agent · SQLite · alarmsfibers · scheduling · state'use agent'agent loop (Pi) · sessionsrecovery · channelsYour functionuseModel · useTool
Agents run your code. Workers for Platforms turns the runtime into a product — your customers deploy their own isolated Workers through your API.
Workers for Platforms
Built for Platforms
"When your product is other people's apps."
Workers for Platforms lets you expose the Workers runtime as a programmable execution layer — your customers deploy isolated Workers through your API, you control the boundaries.
BuilderApp & vibe-coding buildersShip customer Workers from an AI-powered IDE — no infra for the builder to manage
SitesWebsite buildersEvery site gets its own isolated Worker for edge logic, redirects, and content transforms
CommerceE-commerce extensibilityMerchant-written checkout hooks, discount rules, and custom storefront Workers
In production: Shopify Oxygen (storefront hosting) runs on Workers for Platforms dynamic dispatch. Shopify Engineering ↗
Two kinds of developers
The platform developer owns the Dispatch Worker, uploads customer code through the Cloudflare API, and chooses the bindings, limits, and outbound rules. The end customer writes Worker code and can use only the bindings attached by the platform.
Full control
Platform developer
A website builder company, for example.
Owns the Dispatch Worker and upload API
Chooses each customer's bindings
Sets limits and outbound rules
Platform uploads customer code via Cloudflare API
Gets what's granted
End customer
Writes their Worker code on your platform.
env.DB
env.USER_KV
Only if attached by the platform.
Your customers write the code. You decide what it can touch.
Three primitives, one dispatch model: your Dispatch Worker receives requests
→ calls env.DISPATCHER.get(workerName)
to resolve a User Worker by name → proxies into an isolated V8 isolate containing only the code and bindings you granted.
Workers for Platforms dispatch namespace architectureAn HTTP request flows left to right into the Dispatch Worker labelled Your Platform. The Dispatch Worker calls env.DISPATCHER.get(workerName) then userWorker.fetch(request) to route to one of three User Workers inside a Dispatch Namespace named production: client-a-worker, client-b-worker, and client-c-worker. Each User Worker has a green left bar and runs customer code in an isolated V8 isolate with only explicitly granted bindings. Orange packet dots animate along three bezier paths from the Dispatch Worker into each User Worker.REQUESTYOUR PLATFORMDISPATCH NAMESPACE: productionHTTP requestany routeDISPATCH WORKERYour Platformenv.DISPATCHER.get(workerName).fetch(request)client-a-workerisolated V8 isolate · customer code · only granted bindingsclient-b-workerisolated V8 isolate · customer code · only granted bindingsclient-c-workerisolated V8 isolate · customer code · only granted bindings
Isolation by default
Three User Workers, client-a, client-b, and client-c, each connect only to their own D1 and KV resources. Crossed-out dashed lines deny cross-tenant access. Outbound fetch calls pass through the platform's Outbound Worker to allow, block, log, or add authentication headers.
User Worker
client-a
Own D1 · own KV
✕
User Worker
client-b
Own D1 · own KV
✕
User Worker
client-c
Own D1 · own KV
✕ No cross-tenant access
All User Workers
Outbound Worker
Outbound fetch()
Allow · block · log · add auth headers
Only explicitly attached bindings are visible
Untrusted mode (default): no shared cache, even on the same zone
For full isolation: one resource per customerBest practice: all customers in one dispatch namespace
Every tenant sees only what you granted.
Under the hood
See how it actually works — bindings, routing, controls, dispatch steps
EXPAND ▾COLLAPSE ▴
How bindings reach customer code
Attach at upload. Pass data and capabilities per request.
EXPAND ▾COLLAPSE ▴
Bindings attached at upload
Customer code in worker.js goes to the platform backend. The platform calls the Upload User Worker API with metadata.bindings containing a KV namespace and D1 database. The deployed User Worker in the production dispatch namespace receives USER_KV and DB across every request. keep_bindings preserves existing binding types when more are added.
Add more later — keep_bindings keeps existing binding types"keep_bindings": ["kv_namespace"]
Via the API, bindings go in metadata.bindings — not a Wrangler config file
KVR2D1Durable ObjectsQueuesContainers (as a Durable Object)HyperdriveVPCAnalytics Engine
Attach bindings when you deploy each customer's Worker.
Per-request data and capabilities
A request reaches the platform Dispatch Worker, which authenticates and passes props in the second argument to env.DISPATCHER.get. Readable user data and a sealed CONNECTOR capability reach the User Worker. Customer code reads this.ctx.props.userId and calls this.ctx.props.CONNECTOR.invoke, a method defined by the platform. The call goes back to the Dispatch Worker, where credentials remain, and a result returns. The capability is valid only for this request.
DatauserId: user-123, permissions: [read, write]Data — customer code can read it
CONNECTORCapability — customer code can call methods, can't see the secrets
customer-a
User Worker
this.ctx.props.userId
await this.ctx.props.CONNECTOR.invoke()
invoke() · your method
Capability call returns to the Dispatch WorkerThe upper dashed arrow points left from the User Worker to the Dispatch Worker, where the platform's invoke method uses the real credentials. The lower arrow points right, returning the result to the User Worker.Capability call · credentials stay in Dispatch WorkerResult returns to User Worker
↑ CONNECTOR.invoke() calls back to the Dispatch Worker. Credentials stay there.
↓ Result returns to the User Worker.
Valid only for this request — can't be stored and reused later.
Change what a customer can do per request — no redeploy.
What 'Add a database' looks like in practice
example flow
Four steps: the customer clicks Add database in the platform UI; the platform creates a D1 database through the Cloudflare API; the platform re-uploads the customer's Worker with a DB binding and uses keep_bindings for existing binding types; customer code can then call env.DB.prepare. This is an illustrative product flow, not an end-to-end documentation example.
1
Customer clicks “Add database”
In your platform's UI
2
Platform creates a D1 database
Via the Cloudflare API
3
Platform re-uploads the customer's Worker
Attach DB; preserve existing binding types with keep_bindings
4
Customer code can use DB
env.DB.prepare("SELECT ...")
End customers 'configure' bindings through your product — you stay in control.
Custom metadata: attach plan, tier, or flags at deploy time — worker.userMetadata.plan === "pro"
Platform controls
Limits and observability for every User Worker
EXPAND ▾COLLAPSE ▴
Custom limits: cap CPU time and subrequests per User Worker — one noisy tenant cannot degrade others in the Dispatch Namespace
Observability: executions tagged to your Dispatch Worker — route traces and logs through your own pipeline
How it works
How dispatch works in three steps
EXPAND ▾COLLAPSE ▴
1
Bind the Dispatch NamespaceDeclare it in wrangler.jsonc — the runtime injects it as env.DISPATCHER, a typed handle to every User Worker in your namespace.{
"dispatch_namespaces": [
{ "binding": "DISPATCHER", "namespace": "my-platform" }
]
}
2
Choose the User Worker nameDerive workerName from the request — URL path, hostname, a KV lookup, or metadata attached to the worker at deploy time.
3
Forward the requestResolve the named User Worker and proxy the request into its isolated V8 isolate. It receives only the bindings your platform granted it.const userWorker = env.DISPATCHER.get(workerName);
return userWorker.fetch(request);
User Workers are deployed programmatically via the Cloudflare API — no Wrangler required on the customer side.
Not every workload starts as a full-stack app. Many start as an API — new, or one you already run.
APIs and backends
Start with one route. Let the momentum build.
Write a new API, or put a Worker in front of the one you already have — then grow from there. Either way it runs behind Cloudflare's security, connects to your data and private networks, and is observable from day one. Pick your starting point below.
Protect
Before your code runs
Client
Cloudflare network
WAFBot managementDDoS
Already in the request path.
Build
Worker
Start with one fetch(). Add Hono when routes multiply. Use Python where your team or libraries live.
Put it together — compute, AI, storage, media, network, orchestration. This is what changes when "serverless" becomes "platform".
The bigger picture
Workers is not just a serverless function. It is the platform.
Compute is the start, not the product. The product is what you can compose around it — inference next to data, retrieval next to context, state next to coordination, the CDN and WAF already in the request path. That is the platform Workers ships.
And there's more
Stream: Upload once; Cloudflare handles encoding, storage, and global delivery for live and on-demand video.
Images: Transform images at request time — resize, crop, optimize, and serve the right format from the edge.
Pipelines: ETL for raw event streams — turn them into clean analytics data in R2, without running Kafka, Flink, or custom ingestion workers.
AI Search: Add search that understands meaning, not just keywords, with embeddings, vector similarity, and hybrid ranking.
Queues: Absorb traffic spikes, decouple slow work, and process background jobs reliably behind your Worker.
The foundation
Cloudflare global network sits in front of every Worker
Request path through Cloudflare global network to WorkerAn incoming request enters Cloudflare's global network, which applies CDN across 330-plus cities, DDoS protection, WAF with OWASP rules, Bot management, Smart Routing via Argo, Tiered Cache, and Zero Trust Access controls — and more — before the request reaches the Worker.IncomingrequestCLOUDFLARE GLOBAL NETWORKCDN · 330+ citiesDDoS protectionWAF · OWASP rulesBot managementSmart Routing · ArgoTiered CacheZero Trust · Access+ moreWorkerisolate
Every request reaches your Worker through Cloudflare's network first — global delivery, security, routing, caching, and access controls already in the path.
10+ milliondevelopers building on the Cloudflare Developer Platform
Developer platform adoption growthExponential growth chart from Workers launch in 2017 to over 10 million developers by 2026. Milestones: 1M by 2020, 3M by 2022, 5.5M by 2023, 10M plus by 2026.02M5M10M+Launch1M+3M+5.5M10M+20172020202220232026
330+cities worldwide
500K+companies on the platform
2017when Workers first shipped
Focused builder community · Close product feedback loop · Faster collaborative adoption
Where Cloudflare fits
Broad general-purpose clouds cover every workload. Cloudflare is a focused platform, global by default.
Broad general-purpose cloud
Security and runtime as separate services
Full AI range, from training to inference
Region-first deployment
Per-service SDKs and IAM
Broad ecosystem across every workload
Cloudflare — focused, global by default
Security + runtime, one layer
Production AI path — global, provider-flexible
Global by default — 330+ cities
Primitives via bindings, not SDKs
Builder feedback → roadmap
Cost & scalability
Scale up and down to zero.
Pay nothing when idle. No provisioned VMs or containers — billing starts when requests arrive, stops when they don't. Billed on CPU time, not wall-clock — no charge while a Worker waits on I/O.
Performance
Deploy from region: Earth.
Deploy once, run in 330+ cities. Within 50 ms of ~95% of internet users. Smart Placement keeps compute next to data.
Developer experience
All the products you need.
Inference, state, storage, queues, observability — all as bindings. No infrastructure to provision. Just develop.
all the products you need·without provisioning any infrastructure.
So developers can focus on what they enjoy most: develop!
See it live
The build patterns become real demos.
Note: these demos need to be run at together and on RNobre Cloudflare account.
The categories above explain what you can build. These demos show the same
platform primitives in motion: media, agents, real-time state, retrieval, queues, AI, and multi-cloud ingress.
Cloudflare OS · Primitive Explorer
An open-source AI-native workspace, decomposed into the Developer Platform primitives underneath: model choice, agents, durable state, governed tools, isolated execution, and AI observability.
Three videos, three postures: public, origin-restricted, signed-URL gated. Signed video uses the Stream binding to mint short-lived JWTs server-side.
StreamWorkers bindingJWT
AI Agents · Zero Trust
One Agent, one MCP Server Portal, three MCP servers behind Access. Tools discovered at runtime; every call crosses a real Zero-Trust boundary. Workers AI generates images; D1 / R2 / KV store results.
Agents SDKMCP PortalAccessAI Gateway
Agent Council · Durable debate
Four persistent Agents challenge a decision from distinct perspectives, then a rotating proposer synthesizes the trade-offs for a vote. Durable Objects coordinate each council while AI Gateway routes model calls and D1 preserves the transcript.
Agents SDKDurable ObjectsAI GatewayD1
Agent Guardrails · governed execution
An Orchestrator delegates to Worker agents with separate Workspaces, read-only R2 policy data, fetch-tool allowlists, and Workers AI through AI Gateway. The Audit trail shows what the agent can touch — and where the Guardrail stops it.
Docs into R2 → Queue → Workflow → Workers AI embeds → vectors in Vectorize. At chat time, query vector + top matches stitched into the LLM prompt. Six bindings, one Worker.
Cloudflare edge validates and normalises events, pushes clean payloads into a Queue. A GCP Cloud Run backend pulls via HTTP and acks. Bot mitigation, queueing, and AI visibility in one path via AI Gateway.
QueuesAI GatewayWorkersMulti-cloud
Workflows · durable execution
A 9-step space mission: SWAPI fetch → AI analysis → AI risk assessment → human-in-the-loop pause → AI report → KV archive. Arm a mid-flight "bomb" to fail a step — previous outputs stay preserved, retry recovers without re-running the AI calls.
WorkflowsWorkers AIKVstep.waitForEvent
Containers · custom runtimes
Interactive tutorial showing how Containers extend Workers with custom runtimes. Live ISS tracker with 3D globe, lifecycle management, and scaling models (singleton vs load-balanced). Built on Durable Objects — each container is a DO with location affinity and state.
ContainersDurable ObjectsNode.jsLifecycle
Live Rooms · real-time event chat
Scan a QR code and chat live at a fictional MWC: one Durable Object per Room, a General room sharded across 4 DOs with one message order, a VIP Lounge that refuses non-VIP badges itself, and an @assistant Agent that reads live room state through AI Gateway.
Durable ObjectsWebSocketsAgents SDKAI GatewayWorkers AI