D1
What it is
D1 is Cloudflare's serverless SQL database, built on SQLite. You create a database, bind it to a Worker or Pages project, and query it with plain SQL over a small JavaScript API. There are no servers to size or connection pools to manage — Cloudflare handles storage, replication, and scaling, and you pay for the rows you read and write.
Strengths
- Real SQL (SQLite dialect) — familiar
SELECT,JOIN, transactions, and indexes. - Serverless: no provisioning, no connection limits, scales to zero.
- Tight integration with Workers and Pages via a single binding.
- Read replication places copies near users for low-latency reads.
- Cheap for typical app workloads, with a usable free tier.
Trade-offs
- SQLite semantics: huge datasets and very heavy write concurrency are not its sweet spot.
- Per-database size limits mean very large data may need sharding or R2.
- Newer than Postgres/MySQL, so tooling and ecosystem are still maturing.
- Best accessed from the edge; using it from outside Cloudflare is less natural.
When to use it
Pick D1 for app data in a Cloudflare-hosted project: user records, content, settings, session metadata — anything that fits a relational model and lives alongside your Workers or Pages app.
Vibe coding fit
D1 is a strong default when an agent is already building on Workers, because the database, schema, and queries all live in the same project. Ask the agent to keep migrations in versioned .sql files and apply them with Wrangler, so the schema is reproducible. The binding makes querying a one-liner inside the handler.
# wrangler.toml
[[d1_databases]]
binding = "DB"
database_name = "app-db"
database_id = "your-d1-id"
# Create a DB and run a migration
npx wrangler d1 create app-db
npx wrangler d1 execute app-db --file=./schema.sql