Bindings
Learn what a Cloudflare binding is and why Workers are built around them: a permission and an API in one object, with no keys to leak and no URLs to forge, that you can point at different resources without changing your code. For students who've deployed a Worker.
Bindings
On most platforms, your code reaches a database or another service with a URL and a secret key. On Cloudflare, your Worker gets bindings instead: objects on env that are already connected to a resource, like a KV namespace, another Worker, or an AI model. If you took the Workers course, you already added one in “Add a binding”: that showed how to declare and use a binding. This course is about why bindings are designed that way, and what that design lets you do.
You’ll see what a binding actually is, call one Worker from another without a public URL, point the same code at different resources, and finally hand a piece of untrusted code exactly the capabilities you choose and nothing else.
The course follows the ideas in Kenton Varda’s post Why Workers environment variables contain live objects, plus what Cloudflare has shipped since. Every exercise builds on the same Worker, and your agent checks each step itself before marking it complete.
Exercises
- 00.Interview: Tell your agent what you already know about bindings.✓
- 01.Live objects: Give your Worker a plain variable, a secret, and a KV binding, then see for yourself which of them is a string and which is a live object.✓
- 02.Call another Worker: Create a second Worker with no public URL and call a method on it from your first Worker through a service binding.✓
- 03.Swap resources: Run the same Worker code against a local simulation, the real KV namespace, and a second deployment with its own namespace.✓
- 04.Hand out capabilities: Run a piece of untrusted code in a Dynamic Worker that gets exactly one binding you choose, and no network.✓
Paste this into your agent
Copied! Now paste it into your agent. No agent yet? Here's how to get one.