sellCompute
bolt

Workers

Write a function, deploy with one command, and it instantly runs in 330+ cities worldwide — no servers to manage.

330+Cities worldwide
0msCold starts
100KFree requests / day
128MBMemory per Worker
lightbulb

What is Workers?

Cloudflare Workers lets you run small pieces of code (called "functions") on Cloudflare's network without ever renting or maintaining a server. You just write the code; Cloudflare runs it for you, automatically, everywhere.

"Serverless" doesn't mean there are no servers — it means you don't have to think about them. There's no machine to set up, no operating system to patch, and no scaling to plan. Your code wakes up only when a request comes in, runs, and goes back to sleep.

local_cafe

Think of it like…

Renting a normal server is like buying a whole coffee machine, plugging it in 24/7, and paying for electricity even when nobody wants coffee. Workers is like a barista who appears the instant someone orders, makes exactly one cup, and disappears — you only pay per cup.

Because the code runs in the Cloudflare data center physically closest to each visitor ("the edge"), responses come back extremely fast. You can write Workers in JavaScript, TypeScript, Python, or Rust.

help

Why use it?

Traditional servers come with a long list of chores: provisioning machines, keeping them online, handling traffic spikes, and paying even when they sit idle. Workers removes that entire category of work.

rocket_launch

No servers to manage

No machines to provision, patch, or restart at 3am. Cloudflare handles all the infrastructure.

bolt

Zero cold starts

Workers use lightweight V8 isolates instead of containers, so there's no slow "warming up" delay before your first request.

public

Global by default

One deploy puts your code in 330+ cities. Visitors are served from the location nearest them automatically.

trending_up

Scales itself

One request or one million — Workers scales up and down on its own. You never configure auto-scaling.

payments

Pay per request

You're billed for what runs, not for idle time. There's a generous free tier of 100,000 requests a day.

extension

Connects to everything

Bind Workers to storage (KV, R2, D1), queues, AI models, and more with a few lines of config.

target

When should you use it?

Workers shines whenever you want code to run fast, globally, and on demand. Here are common real-world uses.

api

APIs & backends

Build the backend for a mobile or web app — handle requests, talk to a database, return JSON.

web

Full websites

Serve entire sites and frameworks like Next.js, Astro, or React directly from the edge.

alt_route

Routing & redirects

Inspect incoming requests and redirect, rewrite, or A/B test them before they hit your origin.

schedule

Scheduled jobs

Run code on a timer with Cron Triggers — send daily emails, clean up data, fetch feeds.

shield

Auth & middleware

Check tokens, add security headers, or rate-limit requests in front of any application.

smart_toy

AI at the edge

Call AI models and stream responses to users with very low latency using Workers AI.

rocket_launch

How do you get started?

You build and deploy Workers with a free command-line tool called Wrangler. The steps below create a "Hello World" Worker, run it on your own computer, then publish it live to the internet.

  1. Create a new Worker project

    This command scaffolds a ready-to-run project. Choose the "Hello World" template, "Worker only", and JavaScript when prompted.

    bash
    npm create cloudflare@latest -- my-first-worker
    cd my-first-worker
  2. Run it locally

    Start a local development server. Open http://localhost:8787 in your browser to see your Worker respond.

    bash
    npx wrangler dev
  3. Deploy it live

    Publish your Worker to Cloudflare's global network. You'll get a public URL like my-first-worker.<your-subdomain>.workers.dev.

    bash
    npx wrangler deploy
jssrc/index.js — a minimal Worker
export default {
  // This fetch() handler runs on every incoming HTTP request
  async fetch(request, env, ctx) {
    return new Response("Hello World!");
  },
};
settings

What is wrangler.toml?

Every project has a wrangler.toml (or wrangler.jsonc) config file. It holds your Worker's name and any "bindings" — connections to other Cloudflare services like databases or storage. Wrangler reads it when you deploy.

school

Key concepts

function

Handler

The function Cloudflare calls when something happens — fetch() for HTTP requests, scheduled() for cron jobs.

layers

Isolate

A super-lightweight sandbox that runs your code. Thousands share one process, which is why there are no cold starts.

cable

Binding

A secure connection from your Worker to another service (a database, storage bucket, queue). You access it via env.

hub

The edge

Cloudflare's data centers spread across 330+ cities. Your code runs at the one nearest each visitor.

timer

CPU time

How long your code actively computes. Free plan allows 10ms per request; paid defaults to 30s (up to 5 min).

terminal

Wrangler

Cloudflare's command-line tool for creating, testing, and deploying Workers. It's free and runs via npx.

tips_and_updates

Tips & pricing

savings

Start free

The free plan gives you 100,000 requests per day — plenty to build, learn, and launch a small project before you ever pay a cent.

Good limits to remember

  • Free plan: 100,000 requests/day; Paid plan: unlimited requests
  • CPU time: 10ms per request on Free, 30s default (up to 5 min) on Paid
  • Memory: 128 MB per Worker on both plans
  • Worker size: 3 MB compressed on Free, 10 MB on Paid
  • Subrequests: 50 per request on Free, 1,000+ on Paid
warning

Watch your CPU time

CPU time counts only active computation, not time spent waiting for a network response. Heavy loops or large data processing can hit the limit — split big jobs into smaller pieces or use Queues.