Owen Conti

How to add Cloudflare Durable Objects to an environment

under Cloudflare

For some reason, Cloudflare doesn't automatically inherit Durable Objects to environments like it does for the rest of the Worker settings. To get around this, you must define the Durable Objects for each environment. Here's an example using the default Counter example Worker:

1# Default environment
3bindings = [{name = "COUNTER", class_name = "CounterTs"}]
6name = "durable-objects-test-staging"
8# Need to redefine the binding for the `staging` environment
10bindings = [{name = "COUNTER", class_name = "CounterTs"}]

Thanks for reading this article!

Hopefully you found this article useful! If you did, share it on Twitter!

Found an issue with the article? Submit your edits against the repository.