env object. For service worker syntax, bindings appear as global variables.
Structure
Name of the binding. Becomes the property name in
env (ES modules) or the global variable name (service workers).Binding types
Simple values
A string value.
An ArrayBuffer.
A value parsed from JSON.
Service bindings
Binding to a named service (possibly another worker).
Durable Objects
Binding to a Durable Object namespace.In the common case where this refers to a class in the same worker, you can specify just a string:
className: Exported class name implementing the Durable ObjectserviceName: Service name defining the class (optional, defaults to current worker)
A Durable Object class binding without an actual storage namespace. Used to implement facets.
Storage services
A KV namespace. Operations are converted to HTTP requests to the named service.
An R2 bucket binding. Operations are converted to HTTP requests.
An R2 admin API binding.
Queues and events
A Queue binding. Operations are converted to HTTP requests to the named service.
Analytics Engine binding. Allows workers to store information through Analytics Engine Events.Requires
--experimental flag.Database connections
Hyperdrive binding for Postgres database caching and pooling.
designator: ServiceDesignatordatabase: Database nameuser: Usernamepassword: Passwordscheme: Connection scheme
WebAssembly and crypto
A WebAssembly module. The binding is a
WebAssembly.Module instance. Only supported in service worker syntax.Deprecated: Use ES modules syntax with WASM modules instead.A CryptoKey instance for use with the WebCrypto API.By setting
extractable = false, you prevent the worker from accessing raw key material; the key can only be used in WebCrypto operations.Fields:raw,hex,base64: Raw key material (for symmetric keys)pkcs8: Private key in PEM-encoded PKCS#8 formatspki: Public key in PEM-encoded SPKI formatjwk: Key in JSON formatalgorithm: Algorithm name or JSON objectextractable: Allow worker to export key material (default: false)usages: List of permitted operations (encrypt,decrypt,sign,verify,deriveKey,deriveBits,wrapKey,unwrapKey)
Advanced bindings
Wraps a collection of inner bindings with common API functionality.
moduleName: Internal wrapper module nameentrypoint: Function name to call (default: “default”)innerBindings: List of bindings passed to wrapper function
Takes the value from a system environment variable. The binding value is
null if the environment variable is not set.Enables access to the UnsafeEval API.
In-memory cache binding. Multiple isolates can access the same cache within the same process.
id: Cache identifierlimits: MemoryCacheLimitsmaxKeys: Maximum number of keysmaxValueSize: Maximum size of a single valuemaxTotalValueSize: Maximum total size of all values
Dynamically load workers from code at runtime. Acts as a cache, automatically unloading unused workers.
id: Optional identifier for sharing across multiple bindings
Provides a
connect() method to dynamically connect to any workerd instance’s debug port via WorkerdDebugPort RPC interface.For local development and testing only.Parameter bindings
Indicates the worker requires a binding of the given type, but it won’t be specified here. Another worker can inherit this worker and fill in the binding.
type: Expected type of this parameteroptional: If true, derived workers need not specify it (default: false)