Worker Options
These options configure the Worker script and module system.name
string
Unique identifier for the worker. Required when using multiple workers.
script
string
Worker script contents as a string. Mutually exclusive with
scriptPath.scriptPath
string
Path to the worker script file. Mutually exclusive with
script.modules
boolean
default:"false"
Whether the worker uses ES modules format (vs. service worker format).
modulesRoot
string
Root directory for resolving module imports.
modulesRules
ModuleRule[]
Rules for importing non-JavaScript files.
Runtime Options
compatibilityDate
string
Compatibility date in YYYY-MM-DD format.
compatibilityFlags
string[]
Compatibility flags to enable.
routes
string[]
Route patterns this worker handles.
upstream
string
Upstream URL for fetch requests that don’t match routes.
Server Options
host
string
default:"127.0.0.1"
Host to bind the HTTP server to.
port
number
default:"0"
Port for the HTTP server. Use 0 for a random available port.
inspectorPort
number
Port for the Chrome DevTools inspector.
Logging Options
log
Log
Custom logger instance.
verbose
boolean
Enable verbose logging.
Binding Options
bindings
Record<string, any>
Simple environment variables and bindings.
kvNamespaces
Record<string, string>
KV namespace bindings. Map of binding names to namespace IDs.
durableObjects
Record<string, string | DurableObjectOptions>
Durable Object bindings.
r2Buckets
Record<string, string>
R2 bucket bindings. Map of binding names to bucket names.
d1Databases
Record<string, string>
D1 database bindings. Map of binding names to database IDs.
serviceBindings
Record<string, string | ServiceDesignator>
Service bindings to other workers.
queueProducers
Record<string, string | QueueProducerOptions>
Queue producer bindings.
queueConsumers
Record<string, QueueConsumerOptions>
Queue consumer configuration. Map of queue names to options.
analyticsEngineDatasets
Record<string, string>
Analytics Engine dataset bindings.
Persistence Options
defaultPersistRoot
string
Default root directory for all persisted data.
kvPersist
boolean | string
Enable KV persistence.
true uses default path, or specify directory.durableObjectsPersist
boolean | string
Enable Durable Objects persistence.
r2Persist
boolean | string
Enable R2 persistence.
d1Persist
boolean | string
Enable D1 persistence.
cachePersist
boolean | string
Enable Cache API persistence.
Multi-Worker Options
For running multiple workers in the same Miniflare instance:workers
WorkerOptions[]
Array of worker configurations. Each worker has all the options listed above plus a required
name.Advanced Options
cf
object
Custom
request.cf object properties.unsafeEvalBinding
string
Binding name for unsafe eval functionality (for REPL-like use cases).
liveReload
boolean
Inject live reload script into HTML responses.
mounts
Record<string, MiniflareOptions>
Mount other Miniflare instances at specific routes.