Miniflare — Fully-local simulator for Cloudflare Workers

Miniflare is a simulator for developing and testing Cloudflare Workers.

Originally started as an open-source project, Miniflare has been adopted by Cloudflare to become part of their ecosystem.

Installation per NPM:

npm install -g miniflare

CLI usage is really simple, and is highly configurable using one of its many flags:

$ miniflare worker.js
[mf:inf] Worker reloaded! (97B)
[mf:inf] Listening on :8787
[mf:inf] -

Alternatively you can also use it in your own JS code:

import { Miniflare } from "miniflare";

const mf = new Miniflare({
  script: `
  addEventListener("fetch", (event) => {
    event.respondWith(new Response("Hello Miniflare!"));
const res = await mf.dispatchFetch("http://localhost:8787/");
console.log(await res.text()); // Hello Miniflare!

🔥 Miniflare (GitHub) →

🤔 Want to get started with Cloudflare Workers? This guide by Chris Ferdinandi should get you on track.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.