# Cloudflare D1 [[Cloudflare]] D1 is a serverless SQL database built on [[SQLite]], deployed at the edge with read replicas across Cloudflare's network. Each database is a SQLite file managed by Cloudflare; queries run via HTTP from [[Cloudflare Workers]] bindings or REST API, and writes are replicated asynchronously to read replicas in other regions. D1 sits in the same niche as Turso and LiteFS — SQLite-as-a-service, optimized for read-heavy edge workloads. It's not Postgres-class (no advanced types, limited concurrent writes per database) but for most application backends, it's enough — and it's free up to 5M reads/day with no cold starts. ## Why It Matters SQLite is finally a credible primary database for production apps, and D1 makes it serverless-native: bindings, automatic backups (Time Travel — point-in-time restore up to 30 days), no connection pooling problems, no separate scaling concerns. For [[Cloudflare Workers]] apps, D1 is the default relational store. ## Common Use Cases - **App backends** with moderate write volume — SaaS, dashboards, content sites - **Per-tenant databases** — give each customer their own D1 (cheap, isolated) - **Edge-local reads** — replicas serve reads from the nearest POP - **Replacing Postgres** for apps that don't actually need Postgres features ## Limits Worth Knowing - Max database size: 10 GB - Single-writer model (writes serialize through the primary) - No PostgreSQL/MySQL features: no triggers across DBs, no extensions, limited JSON - Reads: free 5M/day, paid $0.001 per million - Writes: free 100K/day, paid $1.00 per million ## References - D1 home: https://www.cloudflare.com/developer-platform/products/d1/ - Documentation: https://developers.cloudflare.com/d1/ - SQLite docs: https://sqlite.org/docs.html ## Related - [[Cloudflare]] - [[Cloudflare Workers]] - [[Cloudflare Hyperdrive]] - [[Cloudflare KV]] - [[Cloudflare Durable Objects]] - [[SQLite]] - [[Wrangler]]