Cloudflare WorkersA developer introduction

Ship code to the network, not to a server.

Serverless functions that run on Cloudflare's global network, scale automatically from zero, and connect to data, storage and AI through bindings.

JavaScriptTypeScriptPythonRust
Source: workers.cloudflare.com01 / 05
Developer workflow02 / 05

From localhost to global.

The loop stays familiar: write, test locally, ship, and control the rollout. Deploy from the CLI or by merging in Git.

01

Start from a template

Pick a starter in JavaScript, TypeScript, Python or Rust.

02

Test it locally

Run the full app on your machine with workerd, the open-source runtime.

03

Deploy from CLI or Git

Push from the terminal, or connect a repository and deploy on merge.

04

Roll out, roll back

Ship everywhere at once or to a percentage of users; roll back if errors spike.

Source: workers.cloudflare.com · "First-class local development", "Go fast, or slow"
Deployment model03 / 05

Deploy once. Run everywhere.

User HTTP request 1 CLOUDFLARE NETWORK Location near user by default, or near your data with Smart Placement 2 V8 ISOLATE Your Worker fetch(request, env) 3 ENV BINDINGS env.DBD1 SQL env.KVkey-value env.BUCKETR2 objects env.AIWorkers AI 4 Response returned
Deploy once

Code runs across Cloudflare's cities by default. No regions to configure.

Isolates, not containers

Lightweight V8 isolates scale up and down quickly, without process overhead.

Scale from zero

Concurrency follows demand; no pre-provisioning or prewarming.

Source: workers.cloudflare.com · "Isolates vs. Containers", "Near your users, or your data"
Capabilities04 / 05

Full stack, via bindings.

index.ts
export default {
  async fetch(request, env) {
    const stmt = env.DB.prepare(
      'SELECT * FROM comments LIMIT 3');
    const { results } = await stmt.all();

    return new Response(renderHtml(results), {
      headers: { 'content-type': 'text/html' },
    });
  },
} satisfies ExportedHandler<Env>;

Query D1 from a Worker. The database arrives as a binding on env; no connection string in code. Adapted from the product page.

Storage & data

D1KVR2QueuesHyperdrive

State & orchestration

Durable ObjectsWorkflowsContainers

AI

Workers AIVectorizeAI GatewayAgents

Also: Browser Rendering, Images and more through the same binding model.

Source: workers.cloudflare.com · "Hello World to full-stack", "Powerful primitives"
Use cases05 / 05

Where Workers fit.

Scalable APIs

Automatic scaling and global deployment, without load balancers or regional config.

Full-stack web apps

React, Vue or Next.js with backend logic, databases and storage alongside.

Edge logic

Auth, rate limiting, routing and caching near users, offloading your origin.

Background jobs

Webhooks, data processing and scheduled tasks with Queues, Workflows and Cron Triggers.

Evaluate it

Start with one route.

Move a single API endpoint or edge rule onto a Worker, test it locally, then roll it out to a share of traffic.

Source: workers.cloudflare.com · "You can use Workers to"