Cloudflare Wrangler
Build and deploy Cloudflare Workers and Pages
Description
Wrangler is the CLI for Cloudflare's developer platform. It lets you create, develop, and deploy Workers (serverless functions at the edge), Pages (static sites), R2 (object storage), D1 (SQLite databases), KV (key-value storage), and other Cloudflare developer services.
Install
npm i -g wranglerAI Summary
Build and deploy Cloudflare Workers, Pages, and developer services. Develop locally with a full edge runtime, manage KV/R2/D1 storage, and deploy serverless functions to Cloudflare's global network.
Capabilities
- + Create and deploy Cloudflare Workers (serverless edge functions)
- + Deploy static sites and full-stack apps to Cloudflare Pages
- + Local development with Miniflare, a full Workers runtime simulator
- + Manage KV namespaces, R2 buckets, and D1 SQLite databases
- + Tail real-time logs from deployed Workers
- + Manage secrets and environment variables
Use When
- → Building and deploying serverless functions on Cloudflare's edge
- → Deploying static sites or full-stack apps to Cloudflare Pages
- → Need edge-first computing with low latency globally
- → Working with Cloudflare storage services (KV, R2, D1)
Avoid When
- x Need long-running server processes (Workers have execution time limits)
- x Locked into another cloud provider's ecosystem
- x Applications requiring traditional server infrastructure
Usage Patterns
Start local development
wrangler dev Runs the Worker locally with hot-reloading and the full Workers API
Deploy a Worker
wrangler deploy Publishes the Worker to Cloudflare's global edge network
Tail production logs
wrangler tail --format pretty Streams real-time request and console logs from the deployed Worker
Create a KV namespace
wrangler kv:namespace create MY_KV Creates a new KV namespace and outputs the binding for wrangler.toml
Input / Output
0 Success 1 Error Typical Pipelines
wrangler deploy && wrangler tail --format json | jq '.logs[]' wrangler kv:key list --namespace-id=abc123 | jq '.[].name' wrangler d1 execute my-db --command 'SELECT * FROM users' --json | jq '.results'