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:Quick Start
Initialize a new Worker project:- A
wrangler.jsoncconfiguration 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:- Hot module reloading for instant updates
- Chrome DevTools integration for debugging
- Local bindings simulation (KV, R2, D1, Durable Objects)
- Request/response inspection
Deployment
Deploy your Worker to production: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:Configuration
Wrangler uses awrangler.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:R2 Buckets
Create an R2 bucket:D1 Databases
Create a D1 database:Queues
Create a queue:Secrets Management
Secrets are encrypted environment variables that aren’t visible in your code. Add a secret:Deployments & Versions
Gradual Rollouts
Wrangler supports gradual rollouts to test changes with a percentage of traffic:Rollback
Quickly rollback to a previous deployment: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:-
Start dev server with inspector:
-
Open
chrome://inspectin Chrome - Click “inspect” next to your Worker
- 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
-
Initialize project:
-
Develop locally:
-
Create resources:
-
Update configuration:
wrangler.jsonc
-
Deploy:
-
Monitor:
Testing with Different Bindings
Test with local bindings during development:Best Practices
Use TypeScript
Use TypeScript
TypeScript provides better IDE support and catches errors before deployment:
Version Control Configuration
Version Control Configuration
Commit
wrangler.jsonc but use secrets for sensitive data:Environment-Specific Configuration
Environment-Specific Configuration
Use environments for different deployment targets:
Test Before Deploying
Test Before Deploying
Always test locally before deploying:
Troubleshooting
Common Issues
Authentication errors:Additional Resources
Related Tools
Miniflare
Local Workers simulator powered by workerd
Create Cloudflare
Scaffold new Cloudflare projects