wrangler dev, which runs your Worker in a local simulator powered by Miniflare and the workerd runtime.
Quick Start
- Hot reload on file changes
- Local bindings simulation (KV, R2, D1, Durable Objects, etc.)
- DevTools debugging support
- Live reload for HTML pages
Development Modes
Local Mode (Default)
Runs your Worker code locally in the workerd runtime with simulated bindings:- Fast iteration speed
- Works offline
- Breakpoint debugging
- No Cloudflare account required for basic development
- Bindings are simulated, not production resources
- Some features may behave differently than production
Remote Mode
Runs your Worker on Cloudflare’s global network:- Uses production bindings and resources
- Exact production behavior
- Access to remote-only features
- Slower iteration (requires upload)
- Requires Cloudflare account
- No breakpoint debugging
Hybrid Mode (Remote Bindings)
Run Worker code locally but connect to remote resources:wrangler.json
Server Configuration
Port and Host
wrangler.json
- Host:
127.0.0.1 - Port:
8787(auto-assigned if busy)
HTTPS Support
Run the dev server with HTTPS:wrangler.json:
wrangler.json
Upstream Configuration
Configure how your Worker connects to origin servers:wrangler.json
Persistence
By default, local bindings use in-memory storage. Enable persistence to retain data across restarts:wrangler.json:
wrangler.json
.wrangler/state/v3/kv/- KV namespaces.wrangler/state/v3/do/- Durable Objects.wrangler/state/v3/r2/- R2 buckets.wrangler/state/v3/d1/- D1 databases
Live Reload
Enable automatic page refresh when your Worker changes:wrangler.json
Environment Variables
.dev.vars File
Store development secrets in.dev.vars (never commit this file):
.dev.vars
env.API_KEY, env.DATABASE_URL, etc.
Environment-Specific Vars
Use.dev.vars.<environment> for environment-specific secrets:
.dev.vars.staging
.env Files
Wrangler also loads.env files if .dev.vars is not present:
.env.<environment>.local.env.local.env.<environment>.envprocess.env(ifCLOUDFLARE_INCLUDE_PROCESS_ENV=true)
.env loading:
Inline Variables
Pass variables via CLI:Miniflare
Wrangler dev uses Miniflare under the hood, which provides:workerd Runtime
The same runtime as production Workers
Binding Simulation
Local KV, R2, D1, Durable Objects, Queues
Hot Reload
Instant updates on file changes
Debugging
Chrome DevTools integration
Miniflare Options
Access advanced Miniflare features through the API:Routes and Triggers
Routes
Define routes for local development:wrangler.json
Scheduled Events
Test Cron Triggers locally:http://localhost:8787/__scheduled in your browser to manually trigger scheduled events.
wrangler.json
Advanced Configuration
Custom Entry Point
Compatibility Settings
No Bundle Mode
Skip the build step for pre-built Workers:Minification
Custom tsconfig
Multi-Worker Development
Develop multiple Workers simultaneously:Interactive Dev Session
When running in an interactive terminal, wrangler dev shows hotkeys:b- Open browserd- Toggle DevToolsl- Toggle local/remote mode (if applicable)c- Clear consolex- Exit
Troubleshooting
Port Already in Use
If port 8787 is busy, wrangler will auto-assign a free port. Or specify a different port:WebContainer Limitation
wrangler dev does not currently work in StackBlitz WebContainers. Use the Cloudflare Workers playground instead.
Live Reload Not Working
- Ensure you’re in local mode (not
--remote) - Check that
--live-reloadis enabled - Verify your HTML pages can connect to the WebSocket
Binding Not Available
If a binding isn’t available inenv:
- Check your
wrangler.jsonconfiguration - Verify
.dev.varsfor secret variables - Ensure binding names match exactly (case-sensitive)
See Also
Configuration
Complete wrangler.json reference
Testing
Test Workers with vitest-pool-workers
Debugging
Debug Workers with DevTools
Bindings
Learn about Worker bindings