Workers basics · Exercise 02
Add a binding
Create a Workers KV namespace, bind it to the Worker you already deployed, and read and write a value through it to prove the binding actually persists data.
Prompt for your agent
Copied! Now paste that into your agent...
Add a binding
This exercise extends the Worker you deployed in Deploy a Worker. You’ll create a Workers KV namespace, bind it to that Worker, and read and write a value through it — the first taste of what a Cloudflare binding is and why it matters. Your agent will guide you end to end.
What you’ll build
The same Worker, now with a KV binding on env. You’ll write a value (e.g. via a query string) and, in a separate request, read it back from the public URL. Getting the same value back proves the binding actually persists data, not that a single request just echoed something. Out of scope: multiple namespaces, TTLs, R2/D1, and other storage.
Prerequisites
Your agent can help you with these.
- You’ve completed Deploy a Worker and still have that project on disk.
- The
cfCLI authenticated against your Cloudflare account (cf auth whoami).