0
Edge cities
<1ms
Cold start time
0
AI models
$0
Egress fees on R2
Compute

Workers & Pages

Serverless compute and frontend hosting built for the edge. Deploy your full‑stack app to 330+ cities with a single command — V8 isolates boot in under a millisecond.

worker.js
export default {
  async fetch(request) {
    const url = new URL(request.url);
    if (url.pathname === "/api/hello") {
      return Response.json({ msg: "Hello from the edge" });
    }
    return new Response("Not found", { status: 404 });
  }
};
worker.ts
interface Env { DB: D1Database; }

export default {
  async fetch(req: Request, env: Env): Promise<Response> {
    const { results } = await env.DB
      .prepare("SELECT * FROM users LIMIT 10")
      .all();
    return Response.json(results);
  }
} satisfies ExportedHandler<Env>;
worker.py
from workers import Response

async def on_fetch(request, env):
    return Response.json({"hello": "earth"})
lib.rs
use worker::*;

#[event(fetch)]
async fn main(req: Request, env: Env, _ctx: Context) -> Result<Response> {
    Response::ok("Hello from Rust on the edge!")
}

Everything Workers can do

⚡

Sub‑ms cold starts

V8 isolates start instantly — your users never wait for a container to spin up.

🌐

Smart Placement

Workers auto‑run close to your data, your users, or your APIs — whichever is fastest.

🔌

Service Bindings

Compose Workers like microservices with zero‑latency RPC between them.

📨

Queues

Durable, exactly‑once messaging for background work and fan‑out pipelines.

🪄

Workflows

Long‑running, durable execution that survives restarts and resumes from any step.

⏰

Cron Triggers

Schedule Workers as cron jobs — no extra infrastructure required.

🔁

WebSockets

Native, hibernation‑aware WebSockets backed by Durable Objects.

🌊

Streaming Responses

Stream LLM tokens, SSR HTML, or media transcodes with Web Streams support.

📈

Observability

Built‑in logs, metrics, traces and Tail Workers — debug production in real time.

Pages

Frontend hosting that ships with every commit.

Connect a Git repo and Cloudflare Pages builds, deploys, and serves your site globally — with preview URLs for every pull request.

  • Native support for Next.js, Astro, Remix, SvelteKit, Nuxt, Hono
  • Unlimited bandwidth on every plan
  • Preview deploys + rollback with one click
  • Functions powered by Workers — same runtime, same speed
terminal
$ git push origin main

▲ Cloudflare Pages
─────────────────────────────────
✓ Cloning repo (4.2s)
✓ Detected framework: Next.js
✓ Building (38s)
✓ Deploying to global edge (3s)

🌍 Preview: my-site-pr-12.pages.dev
✅ Production: my-site.pages.dev
Data

Storage that lives next to your code

Pick the right primitive for the job — objects, SQL, key‑value, vectors, or strongly‑consistent state — all natively bound into your Workers.

R2 — Object storage with zero egress fees

S3‑compatible object storage that doesn't punish you for serving your own data. Perfect for media, datasets, backups and AI training corpora.

  • $0 egress, ever — no surprise bandwidth bills
  • S3‑compatible API for drop‑in migrations
  • Public buckets, signed URLs, or private via Workers
  • Event Notifications via Queues
r2.ts
export default {
  async fetch(req, env) {
    const key = new URL(req.url).pathname.slice(1);
    const obj = await env.MY_BUCKET.get(key);
    if (!obj) return new Response("404", {status:404});
    return new Response(obj.body, {
      headers: { "content-type": obj.httpMetadata.contentType }
    });
  }
}

D1 — Serverless SQL on SQLite

A managed SQL database that scales horizontally and replicates close to your users. Run queries from any Worker with native bindings.

  • SQLite‑compatible — battle‑tested SQL
  • Time‑travel: restore to any point in the last 30 days
  • Read replication built in
  • Migrations via Wrangler
d1.ts
export default {
  async fetch(req, env) {
    const stmt = env.DB.prepare(
      "SELECT id, title FROM posts WHERE author = ?"
    ).bind("ada");

    const { results } = await stmt.all();
    return Response.json(results);
  }
}

KV — Globally replicated key‑value

Eventually consistent KV with single‑digit‑ms reads from every edge location. Ideal for config, feature flags, and cache.

  • Reads cached at every Cloudflare data center
  • Up to 25 MB per value
  • TTL and metadata support
kv.ts
await env.CACHE.put("user:42", JSON.stringify(user), {
  expirationTtl: 3600
});

const hit = await env.CACHE.get("user:42", "json");

Durable Objects — Strongly consistent state at the edge

A unique primitive: a JavaScript class that runs in a single location, coordinates WebSocket connections, and persists state — without a central database.

  • Exactly one instance per ID — no race conditions
  • Built-in SQLite storage with transactional writes
  • Hibernation API cuts costs when idle
  • Perfect for chat rooms, collaborative docs, live counters
counter.ts
export class Counter {
  constructor(private state: DurableObjectState) {}

  async fetch(req: Request) {
    let count = (await this.state.storage.get<number>("count")) ?? 0;
    count++;
    await this.state.storage.put("count", count);
    return Response.json({ count });
  }
}
Intelligence

The AI stack, from model to gateway

Run open‑source models on serverless GPUs, store embeddings, and govern every external AI call — all from one Worker.

rag-worker.ts — Build a RAG pipeline in 30 lines
export default {
  async fetch(req, env) {
    const { question } = await req.json();

    // 1. Embed the question with Workers AI
    const { data: [embedding] } = await env.AI.run(
      "@cf/baai/bge-base-en-v1.5",
      { text: [question] }
    );

    // 2. Search Vectorize for similar passages
    const matches = await env.VECTORIZE.query(embedding.values, {
      topK: 5, returnMetadata: true
    });

    // 3. Ask the LLM with retrieved context
    const context = matches.matches.map(m => m.metadata.text).join("\n");
    const answer = await env.AI.run("@cf/meta/llama-3.1-8b-instruct", {
      messages: [
        { role: "system", content: `Answer using context:\n${context}` },
        { role: "user", content: question }
      ]
    });

    return Response.json(answer);
  }
}

The full AI toolkit

🧠

Workers AI

Run Llama, Mistral, Whisper, Stable Diffusion and 50+ open models on Cloudflare's GPU network. Per‑request pricing — no idle GPU bills.

🧭

Vectorize

Distributed vector database that indexes hundreds of millions of embeddings with sub‑50ms queries from anywhere.

🛡️

AI Gateway

One URL in front of OpenAI, Anthropic, Google, Groq, and self‑hosted models — with caching, rate‑limits, retries and full request logs.

🤖

Agents SDK

Build durable, stateful AI agents on Workers — long‑running tasks, tool use, and human‑in‑the‑loop pause/resume.

🌊

Streaming

Stream tokens directly to the browser with SSE or Web Streams — no buffering, no extra infrastructure.

🔐

Browser Rendering

Headless Chromium as a binding — for screenshots, scraping and AI‑driven web automation.

One gateway, every provider.

AI Gateway sits in front of any model API and gives you observability, caching, fallbacks and budget controls — without changing your client code.

  • Cache identical prompts to slash latency and cost
  • Retry, fallback, and load‑balance across providers
  • Rate‑limit per user, key or IP
  • Full prompt + response logs with PII redaction
openai.ts
import OpenAI from "openai";

const client = new OpenAI({
  // Just swap the base URL — that's it
  baseURL: "https://gateway.ai.cloudflare.com/v1/<account>/my-gateway/openai",
  apiKey: env.OPENAI_KEY,
});

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
});
Plans

Predictable pricing. Generous free tier.

Build for free, then pay only for what you use. No egress fees, no hidden bandwidth charges.

Free

For hobby projects and testing.

$0 / month
  • 100k Workers requests / day
  • 10 GB R2 storage
  • 5 GB D1 storage
  • 10k Workers AI neurons / day
  • Unlimited Pages bandwidth
Start free

Enterprise

For mission‑critical workloads.

Custom
  • Volume discounts
  • 99.99% uptime SLA
  • SAML SSO & advanced RBAC
  • Dedicated solution architects
  • 24/7 phone support
Contact sales

Per‑product pricing at a glance

Pay only for what you use, billed per request, GB or token.

⚡

Workers

$0.30 per million requests after 10M included.

🗄️

R2

$0.015 / GB‑month storage. $0 egress, always.

🐘

D1

$0.001 per 1k rows read. First 25M rows / day free.

🔑

KV

$0.50 per million reads. $5 per million writes.

🧭

Vectorize

$0.04 per 1M queried vector dimensions.

🧠

Workers AI

$0.011 per 1k neurons after free daily allowance.

Frequently asked

Do I really pay $0 for egress on R2?

Yes. R2 has no egress fees — bandwidth out of R2 to your users (or anywhere else) is free. You only pay for storage and operations.

What happens if I exceed the free tier?

On the free plan, requests beyond the daily limit are throttled — your app stays online but slower. Upgrading to Workers Paid removes the limits and bills metered overage.

Can I bring my own custom domain?

Yes. Workers and Pages support custom domains and routes for free, including automatic TLS via Cloudflare.

Is this site real Cloudflare pricing?

No — this is a demo / showcase app. For up‑to‑date official pricing visit cloudflare.com/plans/developer-platform.

Deploy to the edge in under a minute.

From wrangler init to a global Worker — no credit card required to start.