workerd (the same runtime that powers Cloudflare Workers in production), Miniflare provides high-fidelity local development.
Current Version: 4.20260305.0Miniflare requires Node.js 18.0.0 or higher. It’s designed as a lower-level API for tool creators. For most development workflows, use Wrangler or the Cloudflare Vite plugin.
Installation
Install Miniflare as a development dependency:Quick Start
Create a simple Worker instance:Core Features
workerd Runtime
Uses the same runtime as production Workers for accurate simulation
Full API Support
Supports KV, R2, D1, Durable Objects, Queues, and more
DevTools Integration
Debug with Chrome DevTools and sourcemap support
Flexible Persistence
Store data in-memory or persist to disk
Basic Configuration
Module Workers
Service Worker Format
With TypeScript
Bindings
KV Namespaces
R2 Buckets
D1 Databases
Durable Objects
Environment Variables
Queues
Service Bindings
Worker-to-Worker Communication
Custom Fetch Handler
External HTTP Service
Persistence
Miniflare supports flexible persistence options for data storage.In-Memory Storage (Default)
File-System Persistence
Using defaultPersistRoot
HTTP Server
Custom Host and Port
HTTPS Server
Debugging
Chrome DevTools
- Open
chrome://inspectin Chrome - Click “inspect” next to your Worker
- Use breakpoints, console, and profiler
Verbose Logging
Custom Logger
Advanced Features
Live Reload
Changes made via
setOptions() will trigger a page reload when liveReload: true is enabled.Workers Sites / Static Assets
Wrapped Bindings
Create custom bindings with JavaScript:Outbound Service
Intercept all outboundfetch() requests:
Multiple Workers
Testing
Miniflare is perfect for testing Workers:API Reference
Miniflare Constructor
Core Methods
Best Practices
Always Dispose
Always Dispose
Always call
dispose() when you’re done to clean up resources:Use Persistence for Development
Use Persistence for Development
Persist data during development to avoid losing state:
Separate Test Data
Separate Test Data
Use in-memory storage for tests to avoid side effects:
Match Production Configuration
Match Production Configuration
Use the same
compatibilityDate and flags as production:Environment Variables
MINIFLARE_WORKERD_PATH
Use a customworkerd binary:
MINIFLARE_WORKERD_CONFIG_DEBUG
Dump the workerd configuration for debugging:Comparison with Wrangler Dev
Additional Resources
Related Tools
Wrangler
CLI for Workers development and deployment
Vitest Pool Workers
Test Workers with Vitest in the actual runtime