LinuxCommandLibrary

miniflare

TLDR

Start local worker

$ miniflare [worker.js]
copy
Specify port
$ miniflare [worker.js] --port [8787]
copy
With KV namespace
$ miniflare [worker.js] --kv [NAMESPACE]
copy
With D1 database
$ miniflare [worker.js] --d1 [DB]
copy
With environment variables
$ miniflare [worker.js] --env [.env]
copy
Watch for changes
$ miniflare [worker.js] --watch
copy

SYNOPSIS

miniflare [options] [script]

DESCRIPTION

Miniflare is a simulator for Cloudflare Workers. It runs Workers locally with full support for KV, Durable Objects, R2, D1, and other Cloudflare services.
Miniflare enables local development and testing without deploying to Cloudflare.

PARAMETERS

--port port

HTTP port.
--host host
Bind address.
--kv namespace
KV namespace.
--d1 database
D1 database.
--r2 bucket
R2 bucket.
--env file
Environment file.
--watch
Watch for changes.
--wrangler-config file
Wrangler config.

FEATURES

$ - KV storage
- Durable Objects
- R2 buckets
- D1 databases
- Cache API
- Scheduled events
copy

CAVEATS

Behavior may differ from production. Storage is local/temporary. Some features require configuration. Now integrated into Wrangler.

HISTORY

Miniflare was created by Brendan Coll in 2021 to enable local Cloudflare Workers development. It was later officially adopted by Cloudflare.

SEE ALSO

Copied to clipboard