Migrating from Version 2
Last updated Apr 23, 2026
Miniflare v3 now uses workerd ↗︎, the open-source Cloudflare Workers runtime. This is the same runtime that's deployed on Cloudflare's network, giving bug-for-bug compatibility and practically eliminating behavior mismatches. Refer to the Miniflare v3 ↗︎ and Wrangler v3 announcements ↗︎ for more information.
CLI Changes
Miniflare v3 no longer includes a standalone CLI. To get the same functionality, you will need to switch over to Wrangler. Wrangler v3 uses Miniflare v3 by default. To start a local development server, run:
$ npx wrangler@3 dev
If there are features from the Miniflare CLI you would like to see in Wrangler, please open an issue on GitHub ↗︎.
API Changes
We have tried to keep Miniflare v3's API close to Miniflare v2 where possible, but many options and methods have been removed or changed with the switch to the open-source workerd runtime. See the Getting Started guide for the new API docs
Updated Options
kvNamespaces/r2Buckets/d1Databases- In addition to
string[]s, these options now acceptRecord<string, string>s, mapping binding names to namespace IDs/bucket names/database IDs. This means multiple Workers can bind to the same namespace/bucket/database under different names. queueBindings- Renamed to
queueProducers. This either accepts aRecord<string, string>mapping binding names to queue names, or astring[]of binding names to queues of the same name. queueConsumers-
Either accepts a
Record<string, QueueConsumerOptions>mapping queue names to consumer options, or astring[]of queue names to consume with default options.QueueConsumerOptionshas the following type:ts interface QueueConsumerOptions { // /queues/platform/configuration/#consumer maxBatchSize?: number; // default: 5 maxBatchTimeout?: number /* seconds */; // default: 1 maxRetries?: number; // default: 2 deadLetterQueue?: string; // default: none } -
cfFetch - Renamed to
cf. Either accepts aboolean,string(as before), or an object to use a thecfobject for incoming requests.
Removed Options
wranglerConfigPath/wranglerConfigEnv- Miniflare no longer handles Wrangler's configuration. To programmatically start up a Worker based on Wrangler configuration, use the
unstable_dev()API. packagePath- Miniflare no longer loads script paths from
package.jsonfiles. Use thescriptPathoption to specify your script instead. watch- Miniflare's API is primarily intended for testing use cases, where file watching isn't usually required. This option was here to enable Miniflare's CLI which has now been removed. If you need to watch files, consider using a separate file watcher like
fs.watch()↗︎ orchokidar↗︎, and callingsetOptions()with your original configuration on change. logUnhandledRejections- Unhandled rejections can be handled in Workers with
addEventListener("unhandledrejection")↗︎. globals- Injecting arbitrary globals is not supported by
workerd↗︎. If you're using a service worker,bindingswill be injected as globals, but these must be JSON-serialisable. https/httpsKey(Path)/httpsCert(Path)/httpsPfx(Path)/httpsPassphrase- Miniflare does not support starting HTTPS servers yet. These options may be added back in a future release.
cronsworkerd↗︎ does not support triggering scheduled events yet. This option may be added back in a future release.mounts-
Miniflare no longer has the concept of parent and child Workers. Instead, all Workers can be defined at the same level, using the new
workersoption. Here's an example that uses a service binding to increment a value in a shared KV namespace:```ts import { Miniflare, Response } from "miniflare";
const message = "The count is "; const mf = new Miniflare({ // Options shared between Workers such as HTTP and persistence configuration // should always be defined at the top level. host: "0.0.0.0", port: 8787, kvPersist: true,
workers: [ { name: "worker", kvNamespaces: { COUNTS: "counts" }, serviceBindings: { INCREMENTER: "incrementer", // Service bindings can also be defined as custom functions, with access // to anything defined outside Miniflare. async CUSTOM(request) { // `request` is the incoming `Request` object. return new Response(message); }, }, modules: true, script: `export default { async fetch(request, env, ctx) { // Get the message defined outside const response = await env.CUSTOM.fetch("http://host/"); const message = await response.text(); // Increment the count 3 times await env.INCREMENTER.fetch("http://host/"); await env.INCREMENTER.fetch("http://host/"); await env.INCREMENTER.fetch("http://host/"); const count = await env.COUNTS.get("count"); return new Response(message + count); } }`, }, { name: "incrementer", // Note we're using the same `COUNTS` namespace as before, but binding it // to `NUMBERS` instead. kvNamespaces: { NUMBERS: "counts" }, // Worker formats can be mixed-and-matched script: `addEventListener("fetch", (event) => { event.respondWith(handleRequest()); }) async function handleRequest() { const count = parseInt((await NUMBERS.get("count")) ?? "0") + 1; await NUMBERS.put("count", count.toString()); return new Response(count.toString()); }`, }, ],}); const res = await mf.dispatchFetch("http://localhost"); console.log(await res.text()); // "The count is 3" await mf.dispose(); ```
-
metaProvider - The
cfobject andX-Forwarded-Proto/X-Real-IPheaders can be specified when callingdispatchFetch()instead. A defaultcfobject can be specified using the newcfoption too. durableObjectAlarms- Miniflare now always enables Durable Object alarms.
globalAsyncIO/globalTimers/globalRandomworkerd↗︎ cannot support these options without fundamental changes.actualTime- Miniflare now always returns the current time.
inaccurateCpu- Set the
inspectorPort: 9229option to enable the V8 inspector. Visitchrome://inspectin Google Chrome to open DevTools and perform CPU profiling.
Updated Methods
setOptions()- Miniflare v3 now requires a full configuration object to be passed, instead of a partial patch.
Removed Methods
reload()- Call
setOptions()with the original configuration object to reload Miniflare. createServer()/startServer()- Miniflare now always starts a
workerd↗︎ server listening on the configuredhostandport, so these methods are redundant. dispatchScheduled()/startScheduled()- The functionality of
dispatchScheduledcan now be done viagetWorker(). For more information read the scheduled events documentation. dispatchQueue()- Use the
queue()method on service bindings or queue producer bindings instead. getGlobalScope()/getBindings()/getModuleExports()- These methods returned objects from inside the Workers sandbox. Since Miniflare now uses
workerd↗︎, which runs in a different process, these methods can no longer be supported. addEventListener()/removeEventListener()- Miniflare no longer emits
reloadevents. As Miniflare no longer watches files, reloads are only triggered by initialisation orsetOptions()calls. In these cases, it's possible to wait for the reload with eitherawait mf.readyorawait mf.setOptions()respectively. Response#waitUntil()workerd↗︎ does not support waiting for allwaitUntil()ed promises yet.
Removed Packages
@miniflare/*- Miniflare is now contained within a single
miniflarepackage.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers/testing/miniflare/migrations/from-v2/#page","headline":"Migrating from Version 2","description":"Migrate from Miniflare v2 to v3, which uses the workerd runtime for full Workers compatibility.","url":"https://developers.cloudflare.com/workers/testing/miniflare/migrations/from-v2/","inLanguage":"en","image":"https://developers.cloudflare.com/workers/testing/miniflare/migrations/from-v2/og.png?v=ec034876a0a58153","dateModified":"2026-04-23","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: "Access to the default cache is enabled by default:" title: Cache image: https://developers.cloudflare.com/workers/testing/miniflare/storage/cache/og.png?v=89dcc60196ea13c5
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt
Use this file to discover all available pages before exploring further.
Docs