Search

Search pages, services, tech stack, and blog posts

Cloudflare D1

Cloudflare D1 DatabaseSQLite at the edge, globally distributed

Cloudflare D1 brings SQLite to the edge — your database runs in the same data centre as your Cloudflare Worker, eliminating the latency of a remote database call entirely. Full SQL, D1 console, and Wrangler migrations included.

Cloudflare D1 is a serverless SQLite database that runs at the edge, co-located with your Cloudflare Workers. Your database and compute share the same data centre, eliminating the round-trip latency of remote database calls entirely. D1 provides full SQLite SQL compatibility (JOINs, transactions, FTS5, JSON functions), Wrangler CLI migrations, automatic read replication, and a web-based D1 Console. Paired with Drizzle ORM, you get type-safe queries on a globally distributed SQLite database.

Quick start

bash
# Create a D1 database
npx wrangler d1 create myapp

# Run a migration
npx wrangler d1 execute myapp --local --file=./schema.sql

# Or use Drizzle Kit with D1
npm install drizzle-orm
npx drizzle-kit generate
npx wrangler d1 migrations apply myapp

Read the full documentation at developers.cloudflare.com/d1/

Co-located with Workers

Database and compute in the same PoP — sub-millisecond query latency without a remote round-trip.

Full SQLite SQL

Complete SQLite compatibility — JOINs, transactions, FTS5, and JSON functions all work.

Wrangler migrations

SQL migration files managed via Wrangler CLI — versioned schema changes checked into source control.

D1 Console

Query your database from the Cloudflare dashboard — browse tables, run SQL, and inspect schema.

Automatic replication

D1 replicates reads globally — low-latency reads from any Cloudflare region.

Drizzle & Prisma support

Use Drizzle ORM or raw D1 client bindings — typed queries without writing SQL strings.

Why it's hard

Write latency to primary region

D1 replicates reads globally but writes go to the primary region. Write-heavy workloads may experience higher latency from distant regions.

SQLite feature boundaries

D1 inherits SQLite's limitations — no stored procedures, limited ALTER TABLE support, and single-writer concurrency. Design schemas with these constraints in mind.

Migration workflow differences

D1 uses Wrangler CLI for migrations, which differs from traditional ORM migration flows. Drizzle Kit's D1 integration bridges this gap with familiar schema-diff migrations.

Best practices

Use Drizzle ORM with D1

Drizzle's D1 driver provides type-safe queries with zero overhead — your TypeScript types match your SQLite schema exactly.

Keep databases small and focused

D1 works best with focused databases per service rather than one massive database. Use multiple D1 databases for different concerns.

Use Wrangler for local development

wrangler dev --local runs D1 locally with a real SQLite file — test your Workers and database queries without deploying.

Frequently asked questions



Want to build with Cloudflare D1?

Talk to our engineering team about your Cloudflare D1 architecture. We'll respond within 24 hours.

1 spot available in May 2026Apr 2026 fully booked

We limit intake each month so every project gets the focus it deserves.