Hyperdrive foundations

Choose Hyperdrive or D1

Keep an existing full database when its features and ownership matter, or choose D1 for a Cloudflare-native SQLite application.

8 minute lesson

~~~

Hyperdrive and D1 both give a Worker a SQL database, and that surface similarity confuses people. They answer different questions.

Hyperdrive connects Workers to supported existing PostgreSQL and MySQL-compatible databases. The database remains the source of truth and keeps its extensions, operational model, and location. Hyperdrive is an accelerator in front of it, not a replacement for it:

{
  "hyperdrive": [
    { "binding": "HYPERDRIVE", "id": "57b7076f58be42419276f058a8968187" }
  ]
}

D1 is managed SQLite on Cloudflare. There is no server to run, and the database lives inside the platform:

{
  "d1_databases": [
    { "binding": "DB", "database_name": "notes-app", "database_id": "f4b1..." }
  ]
}

The questions that decide it

Choose from schema features, existing data, team operations, latency, migration cost, and consistency — not from the idea that one is universally newer.

Do you already have a database? Two years of production Postgres, with backups, dashboards, and a team that knows it, is an asset. Hyperdrive keeps all of it and removes the connection latency. Migrating that to D1 means rewriting Postgres-specific SQL for SQLite and re-answering every operational question, and “we get to delete Postgres” is rarely worth that bill.

Do you need Postgres features? Extensions like PostGIS or pgvector, stored procedures, and advanced types exist in Postgres. SQLite has a smaller surface. If your schema leans on them, the decision is made.

Is this a brand-new small app? A notes application with a handful of tables has nothing to migrate and no operations team. D1 wins on ceremony: create the database, write the schema, done. No credentials, no pooling, nothing to patch.

Work through both cases

Take an existing Postgres SaaS database and a new small notes application, and justify one storage choice for each.

The SaaS database points at Hyperdrive: real data, real integrations, Postgres features in use. The notes app points at D1: no history, trivial schema, and the entire operational model disappears into the platform. If you argued the reverse for either, write down which concrete feature or constraint drove it — that reasoning, not the tool’s age, is the answer that survives review.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →