Skip to main content
Miniflare is a fully-featured, local simulator for developing and testing Cloudflare Workers. Built on top of 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

Generate a self-signed certificate for local development:

Debugging

Chrome DevTools

Then:
  1. Open chrome://inspect in Chrome
  2. Click “inspect” next to your Worker
  3. 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 outbound fetch() requests:

Multiple Workers

Testing

Miniflare is perfect for testing Workers:

API Reference

Miniflare Constructor

Core Methods

Best Practices

Always call dispose() when you’re done to clean up resources:
Persist data during development to avoid losing state:
Use in-memory storage for tests to avoid side effects:
Use the same compatibilityDate and flags as production:

Environment Variables

MINIFLARE_WORKERD_PATH

Use a custom workerd binary:

MINIFLARE_WORKERD_CONFIG_DEBUG

Dump the workerd configuration for debugging:

Comparison with Wrangler Dev

For most development workflows, use Wrangler Dev. Use Miniflare when you need programmatic control or are building tooling.

Additional Resources

Wrangler

CLI for Workers development and deployment

Vitest Pool Workers

Test Workers with Vitest in the actual runtime