Wrangler Wiki

// LLM knowledge base for Cloudflare's Wrangler CLI · Workers · Pages · Queues · Dynamic Workers · Tunnel

How to use this wiki (for humans and LLMs) Every command, resource, binding, and concept in Wrangler has one node. Each node has a stable #id, a type badge, a one-paragraph description, and chips linking to neighbors. Load this page as context when an LLM needs to reason about Wrangler instead of crawling the docs.
                          ┌─────────────────────────────┐
                          │       wrangler.toml         │
                          │   (or wrangler.jsonc)       │
                          └────────────┬────────────────┘
                                       │
   ┌────────────┬────────────┬─────────┴─────────┬────────────┐
   ▼            ▼            ▼                   ▼            ▼
 Worker       Pages       Queues       Dynamic Workers     Containers
  │            │            │           (dispatch ns)         │
  └─ bindings ─┴─ KV ─ R2 ─ D1 ─ Vectorize ─ AI ─ Hyperdrive ─┘
                          │
                          └── Workflows (durable execution) · Cron · DOs

   sibling: cloudflared (Tunnel)  ·  companion: c3 (create-cloudflare)

Commands

wrangler init / npm create cloudflarecommand

Bootstrap a new project. Modern flow: npm create cloudflare@latest (alias c3) — picks Worker/Pages/Workflow/Queue template, scaffolds.

wrangler devcommand

Local dev server using workerd (the actual edge runtime). Hot reload on save. --remote runs against real edge for real KV/R2/D1.

wrangler deploycommand

Push the Worker to production. --env staging for environments. --dispatch-namespace for Workers for Platforms.

wrangler tailcommand

Live-tail logs from a deployed Worker. Filter by status, sampling rate, IP. Last-resort prod debugger.

wrangler versions {upload,deploy}command

Gradual deploys. upload stages a version without promoting; deploy promotes with a traffic split. Pair with rollback.

wrangler rollbackcommand

Roll back the live deployment to a prior version id. Effectively instant — no rebuild.

wrangler login / logout / whoamicommand

OAuth flow with optional --scopes for least-privilege. whoami prints account + scopes. CLOUDFLARE_API_TOKEN bypasses for CI.

wrangler typescommand

Auto-generates worker-configuration.d.ts from your bindings. Re-run after editing wrangler.toml. --x-include-runtime pulls in workers-types.

wrangler secret {put,list,delete,bulk}command

Encrypted env vars. secret bulk ./secrets.json for upload. Local dev uses .dev.vars file (gitignored).

wrangler triggers deploycommand

Sync trigger config (cron, custom domains, routes) without redeploying code.

Resources

Workerresource

ESM module exporting handlers — fetch, scheduled, queue, email, tail, trace. Bundled, uploaded, bound to a workers.dev subdomain or custom route.

Pages projectresource

Static site + optional Functions. wrangler pages {project,deploy,deployment}. Used by every site under organized-ai-hub.

KV namespaceresource

Eventually-consistent key/value. wrangler kv namespace create. Read-after-write may lag tens of seconds globally.

R2 bucketresource

S3-compatible object storage, no egress fees. wrangler r2 bucket create + r2 object put/get/delete.

D1 databaseresource

Serverless SQLite at the edge. wrangler d1 create, execute, migrations create/apply, export.

Queueresource

Durable message bus. wrangler queues create. At-least-once delivery; configure max-retries + DLQ.

Vectorize indexresource

Vector index for RAG. wrangler vectorize create --dimensions=1536 --metric=cosine. Insert/query NDJSON or via binding.

Workers AIresource

Model catalog at the edge. wrangler ai models, ai run @cf/meta/llama-3.1-8b-instruct. Bound as env.AI.run(model, input).

Hyperdriveresource

Connection-pool front of Postgres / MySQL — for Workers that need a real RDBMS. wrangler hyperdrive create --connection-string=....

Durable Object namespaceresource

Strongly-consistent stateful actors. One DO instance per id, globally. SQLite-storage DOs are the modern default.

Workflowresource

Durable execution — multi-step processes that survive failures. Each step's result is checkpointed; resumes from the last completed step.

Containerresource

Real OCI containers alongside Workers. For ffmpeg, headless Chromium, Python ML — anything that doesn't fit the V8 isolate model.

Dispatch namespaceresource

Holds tenant Workers for Workers for Platforms. wrangler dispatch-namespace create/list/delete. Tenants wrangler deploy --dispatch-namespace=....

Cron triggerresource

Scheduled invocations. Configure under [triggers] crons = [...] in wrangler.toml. Maps to scheduled() handler.

Secretresource

Encrypted env var bound at runtime. Set with wrangler secret put NAME. Local dev mirror is .dev.vars.

Bindings (env.* in code)

KV bindingbinding

env.MY_KV.get(key) · put(key, value, { expirationTtl }) · list({ prefix }). Eventually consistent.

R2 bindingbinding

env.MY_BUCKET.put(key, body) · get(key) · list() · delete(key). Multipart for large objects.

D1 bindingbinding

env.DB.prepare(sql).bind(args).all() · first() · run() · batch([stmt1, stmt2]). SQLite at the edge.

Queue producer bindingbinding

env.MY_Q.send(msg) · sendBatch([msg1, msg2]). Producer Worker → Queue.

Queue consumer handlerbinding

Worker exports queue(batch, env, ctx). Per-message msg.ack() · msg.retry({ delaySeconds }) · DLQ on max-retries.

AI bindingbinding

env.AI.run(model, input). Models are catalog ids like @cf/meta/llama-3.1-8b-instruct · @cf/openai/whisper.

Vectorize bindingbinding

env.IDX.insert([{id, values, metadata}]) · query(vec, { topK }) · getByIds().

Hyperdrive bindingbinding

env.PG.connectionString — pass to your pg/mysql client. Hyperdrive pools and caches under the hood.

DO bindingbinding

env.NS.idFromName(name).get() returns a stub. stub.fetch(req) routes to that DO instance globally.

Service bindingbinding

Worker → Worker call without leaving Cloudflare's network. env.OTHER.fetch(req). Zero-egress, in-isolate.

Dispatch namespace bindingbinding

env.DISPATCHER.get(scriptName).fetch(req) — load and run a tenant Worker by name. Heart of WFP.

Container bindingbinding

Reach a containerized sidecar from a Worker. Implemented as a class similar to a DO; instances live across Cloudflare's network.

Config

wrangler.toml / wrangler.jsoncconfig

Project-root config. Declares name, main, compatibility_date, compatibility_flags, bindings, environments, triggers, builds.

.dev.varsconfig

Local dev secrets file at repo root. Gitignored. Mirrors what wrangler secret put sets in prod.

worker-configuration.d.tsconfig

Auto-generated TS interface for Env — every binding declared in wrangler.toml becomes a typed property. Re-run wrangler types after edits.

.wrangler/config

Wrangler's local cache + state dir. Local D1 sqlite, KV simulators, build artifacts. Gitignored.

[env.name]config

Named environments inside one config file. [env.staging], [env.staging.vars], [[env.staging.kv_namespaces]]. Deploy with --env staging.

Concepts

compatibility_dateconcept

Pins runtime semantics. Cloudflare ships breaking changes behind dated flags; compatibility_date freezes you to a known build. Update deliberately.

compatibility_flagsconcept

Opt into / out of specific runtime features (nodejs_compat, web_socket_compression, etc.) independent of date.

bindingsconcept

Typed handles injected as env.<NAME>. Each Cloudflare resource a Worker uses is declared as a binding. Generates types via wrangler types.

ESM modules vs Service Workerconcept

Modern Workers are ESM (export default { fetch }). Service Worker syntax (addEventListener('fetch', …)) is legacy — don't start new projects there.

local vs remote devconcept

wrangler dev = workerd locally with stub bindings. wrangler dev --remote = real edge with real KV/R2/D1. Trade speed for fidelity.

Durable executionconcept

Workflows checkpoint each step's result (not local variables). If the Worker dies mid-flow, it resumes from the last completed step. Wrap stateful ops in step.do().

DO migrationsconcept

Adding/renaming a DO class needs a migration entry under [[migrations]] with a unique tag. new_sqlite_classes for SQLite-storage DOs.

Gradual deploysconcept

Stage a version with wrangler versions upload; promote with traffic split via wrangler versions deploy. Roll back instantly with wrangler rollback.

Authconcept

Local: wrangler login OAuth. CI: CLOUDFLARE_API_TOKEN env var with scoped token. Use scopes, not global keys.

Workers for Platforms (Dynamic Workers)

WFP — what it isconcept

Run user-supplied Workers inside your own Worker. Multi-tenant, per-tenant isolated, per-tenant quota. Used by Shopify Hydrogen, Snyk Composer, and similar.

WFP flowconcept

(1) Create dispatch namespace · (2) Tenants wrangler deploy --dispatch-namespace=<ns> · (3) Your dispatch Worker calls env.DISPATCHER.get(name).fetch(req).

outbound proxyconcept

Configure outbound = { service = "outbound-proxy" } on the dispatch binding so every fetch() from tenant code is funneled through your proxy Worker — for rate limiting, cost capping, allowlists.

Queues — deeper look

producer → queue → consumerconcept

Producer Worker calls env.Q.send(msg). Consumer Worker exports queue(batch, env, ctx). Same Worker can do both.

batchingconcept

max_batch_size (count) · max_batch_timeout (seconds, not ms — easy gotcha) · max_batch_bytes.

dead-letter queueconcept

After max_retries, message moves to dead_letter_queue. Always create the DLQ before going live; otherwise bad batches drop silently.

HTTP pullconcept

wrangler queues consumer http add <queue> exposes pull/ack/retry endpoints — for non-Worker consumers (e.g. a process on claw draining the queue).

Cloudflare Tunnel — sibling, separate CLI

cloudflaredsibling tool

Outbound-only encrypted tunnel from a private origin (laptop, claw, home-lab) to Cloudflare's edge. Different binary from wrangler; brew install cloudflared.

tunnel create / list / deletecommand

cloudflared tunnel create my-tunnel mints a UUID and credentials file. list enumerates, delete tears down.

tunnel route dnscommand

Map a hostname to a tunnel: cloudflared tunnel route dns my-tunnel app.example.com. Creates a CNAME pointing at the tunnel.

~/.cloudflared/config.ymlfile

Ingress rules — host → local URL. Last rule typically service: http_status:404 as catch-all. Run with cloudflared tunnel run my-tunnel.

cloudflared service installcommand

Run as a system service (launchd / systemd) so the tunnel stays up across reboots. Pair with service uninstall to tear down.

Tunnel + Workers patternpattern

Worker on edge enforces auth (Cloudflare Access or JWT); Tunnel exposes the origin only to traffic that's already passed. Free WAF + edge rate limiting in front of localhost.

Companion tools

c3 (create-cloudflare)companion

npm create cloudflare@latest. Templated bootstrap for Worker / Pages / Queue / Workflow / Vectorize / D1 projects. Generates wrangler.toml.

workerdruntime

The actual Workers runtime, open-source. wrangler dev uses it locally — same code path as production, not a simulator.

miniflareruntime

Used internally by wrangler dev for binding stubs (KV, R2, D1, DO). Programmatic API for embedding Workers in tests.

@cloudflare/vitest-pool-workerstesting

Vitest pool that runs tests inside workerd with real bindings. The supported Workers test path.

cloudflare/wrangler-actionci

GitHub Actions wrapper. uses: cloudflare/wrangler-action@v3 + scoped CLOUDFLARE_API_TOKEN.

@cloudflare/workers-typesnpm

Ambient TS types for the Workers runtime — Request, Response, KVNamespace, R2Bucket, etc. Re-exported by wrangler types --x-include-runtime.

Docs & refs

developers.cloudflare.com/workers/wranglerdocs

Canonical reference for every command and config option.

Workers for Platforms docsdocs

Dispatch namespaces, outbound proxies, tags, tenant management.

Queues docsdocs

Producer/consumer config, batching, DLQ, HTTP pull.

Cloudflare Tunnel docsdocs

cloudflared install, config, ingress rules, Access integration.

workers-sdk repogithub

Source for wrangler, miniflare, c3, workers-types — all in one monorepo.

wrangler-guide (sibling)guide

Narrative how-to companion to this wiki — install, dev loop, every primitive, queues + dynamic workers + tunnel walkthroughs.