Course lesson 06 · Building on Cloudflare Workers

Binding resources to your Worker

One study unit · Read, recall, then practice · Original video 00:06:59

Bindings connect a Worker to a Cloudflare resource through its runtime environment. The lesson demonstrates the recurring pattern with KV: create a namespace, declare it in Wrangler, regenerate types, then read and write through the binding. The same discovery process extends to other Cloudflare products, reducing the amount of connection setup repeated in application code.

Primary source: course video 06 · Supplied English subtitles · 00:06:59.

Understand the idea

What the course does

  1. Create the demonstration KV namespace in the Cloudflare dashboard.
  2. Add its namespace ID and an application-facing binding name to the Worker’s Wrangler configuration.
  3. Run the script that invokes Wrangler type generation so the binding becomes visible to TypeScript.
  4. Add one route that stores a supplied ID under a fixed key and another route that reads that key.
  5. Run locally, write two different IDs in sequence, and confirm the read route reflects the persisted state in the demonstration environment.

Watch for

Recall before revealing

What is the difference between a KV resource ID and its binding name?

Reveal the explanation

The ID selects the namespace in Cloudflare; the binding name is the environment property through which this Worker accesses it.

Try it

Reproduce the demonstration with an isolated test KV namespace and explain where the saved ID lives during your chosen development mode.

Check your result

The read route retrieves the saved value, and you can identify the configuration, generated type, and method call involved.

Practice prompts and answer checks are added teaching material. Answer from memory first, then compare and explain any difference.

Rewatch only what you need

Open this lesson in your original course library and seek to the times below. Videos are not hosted on this site.

Companion primary documentation: Cloudflare resource bindings. For recorded API names, commands, limits, and prices, check the version you use.

← Previous   Next →