Skip to main content
Wrangler is the official command-line tool for developing, testing, and deploying Cloudflare Workers. It provides a complete development workflow from local development to production deployment.
Current Version: 4.69.0Wrangler requires Node.js 20.0.0 or higher and is supported on macOS 13.5+, Windows 11, and Linux distros with glib 2.35+.

Installation

Install Wrangler globally or as a project dependency:
Verify installation:

Quick Start

Initialize a new Worker project:
This creates a new Worker with:
  • A wrangler.jsonc configuration file
  • A basic Worker script in src/index.ts
  • TypeScript configuration
  • Package.json with necessary dependencies

Core Features

Local Development

Run your Worker locally with live reloading and Chrome DevTools debugging

One-Click Deploy

Deploy to Cloudflare’s global network with a single command

Resource Management

Create and manage KV namespaces, R2 buckets, D1 databases, and more

Secrets Management

Securely manage environment variables and secrets

Essential Commands

Development

Start a local development server with live reloading:
The dev server provides:
  • Hot module reloading for instant updates
  • Chrome DevTools integration for debugging
  • Local bindings simulation (KV, R2, D1, Durable Objects)
  • Request/response inspection
Access DevTools by visiting chrome://inspect in a Chromium-based browser and clicking “inspect” next to your Worker.

Deployment

Deploy your Worker to production:
Deploy to a specific environment:
By default, Workers are deployed to <worker-name>.<subdomain>.workers.dev. You can add custom domains in the Cloudflare dashboard.

Tail Logs

Stream live logs from your deployed Worker:
Filter logs by status:

Configuration

Wrangler uses a wrangler.jsonc, wrangler.json, or wrangler.toml file for configuration. The JSON format is recommended for better IDE support.

Basic Configuration

wrangler.jsonc

Configuration with Bindings

wrangler.jsonc

Multi-Environment Configuration

wrangler.jsonc

Resource Management

KV Namespaces

Create a KV namespace:
List namespaces:
Manage keys:

R2 Buckets

Create an R2 bucket:
List buckets:
Manage objects:

D1 Databases

Create a D1 database:
Execute SQL:
Run migrations:

Queues

Create a queue:
List queues:

Secrets Management

Secrets are encrypted environment variables that aren’t visible in your code. Add a secret:
List secrets:
Delete a secret:
Bulk upload secrets from a file:

Deployments & Versions

Gradual Rollouts

Wrangler supports gradual rollouts to test changes with a percentage of traffic:

Rollback

Quickly rollback to a previous deployment:
View deployment history:

Advanced Features

Durable Objects

Generate a Durable Object class:

Workers for Platforms

Manage dispatch namespaces:

Analytics Engine

Query analytics data:

Workflows

Manage Cloudflare Workflows:

Programmatic API

Wrangler can be used programmatically in Node.js applications:

Debugging

Chrome DevTools

Wrangler integrates with Chrome DevTools for debugging:
  1. Start dev server with inspector:
  2. Open chrome://inspect in Chrome
  3. Click “inspect” next to your Worker
  4. Use breakpoints, console, and profiler

Verbose Logging

Enable verbose output for troubleshooting:

Configuration Schema

Wrangler provides a JSON schema for IDE autocompletion:
wrangler.jsonc

Common Workflows

Local Development to Production

  1. Initialize project:
  2. Develop locally:
  3. Create resources:
  4. Update configuration:
    wrangler.jsonc
  5. Deploy:
  6. Monitor:

Testing with Different Bindings

Test with local bindings during development:
Using --remote runs your code on Cloudflare’s network with production bindings. Use carefully to avoid unintended changes.

Best Practices

TypeScript provides better IDE support and catches errors before deployment:
Commit wrangler.jsonc but use secrets for sensitive data:
Use environments for different deployment targets:
Always test locally before deploying:

Troubleshooting

Common Issues

Authentication errors:
Build errors:
Port already in use:

Additional Resources

Miniflare

Local Workers simulator powered by workerd

Create Cloudflare

Scaffold new Cloudflare projects