Cloudflare Docs
Durable Objects
Edit this page on GitHub
Set theme to dark (⇧+D)

Environments

Wrangler allows you to deploy the same Worker application with different configuration for each environment.

If you are using Wrangler environments, you must specify any Durable Object bindings you wish to use on a per-environment basis.

Durable Object bindings are not inherited. For example, you can define an environment named staging as below:

wrangler.toml
[env.staging]
durable_objects.bindings = [
{name = "EXAMPLE_CLASS", class_name = "DurableObjectExample"}
]

Because Wrangler appends the environment name to the top-level name when publishing, for a Worker named worker-name the above example is equivalent to:

wrangler.toml
[env.staging]
durable_objects.bindings = [
{name = "EXAMPLE_CLASS", class_name = "DurableObjectExample", script_name = "worker-name-staging"}
]

"EXAMPLE_CLASS" in the staging environment is bound to a different Worker code name compared to the top-level "EXAMPLE_CLASS" binding, and will therefore access different Durable Objects with different persistent storage.

If you want an environment-specific binding that accesses the same Objects as the top-level binding, specify the top-level Worker code name explicitly:

wrangler.toml
[env.another]
durable_objects.bindings = [
{name = "EXAMPLE_CLASS", class_name = "DurableObjectExample", script_name = "worker-name"}
]