What are Cloudflare Workers, D1, R2 and KV?
They are Cloudflare building blocks: Workers run your code, D1 is a SQL database, R2 stores files and KV is a fast key-value store.
In plain terms:
- Workers are small programs that run on Cloudflare's servers around the world, close to your users. A Worker receives a web request and returns a response: a page, data for an API or a redirect. You deploy one with Wrangler, Cloudflare's command-line tool.
- D1 is a SQL database based on SQLite. Use it for structured records with relationships, such as users, orders and posts. You change its tables with migrations, numbered SQL files applied in order.
- R2 is object storage for files such as images, uploads and backups, the kind of thing you'd never put in a database row.
- KV is a key-value store: you save a value under a name and read it back quickly from anywhere. Changes can take a while to reach every location, so it suits data that is read often and changes rarely, like settings or cached results.
Your Worker reaches these through bindings, named connections set in its configuration file, so no database passwords sit in your code.
Cloudflare also offers Durable Objects for state that must stay consistent, plus queues and scheduled jobs.
Vumbli's Ship It track has you deploy a Worker with a D1 database. The Cloudflare Platform Deep Dive covers bindings, KV, R2, D1, Durable Objects, cron, queues and Workers AI, and ends with a live URL shortener.
Start with these missions
- Workers: the fetch handler and env bindings (Cloudflare Platform Deep Dive)
- wrangler.jsonc, environments and custom domains (Cloudflare Platform Deep Dive)
- Git & GitHub in 15 minutes (Ship It)
- Deploy your first site to Cloudflare (Ship It)
Tracks that teach it
More questions, answered by building