Drizzle ORM
A lightweight, zero-dependency TypeScript ORM with full SQL-like query flexibility
Repository Health
Technical Analysis
Drizzle ORM is a TypeScript-first ORM and SQL query builder built around the idea that you should never have to leave SQL-like syntax to get type safety. It ships as a headless, ~7.4kb library with zero runtime dependencies, and supports PostgreSQL, MySQL, SQLite, and SingleStore across every major JavaScript runtime, including Node.js, Bun, Deno, Cloudflare Workers, and edge functions.
Rather than hiding the database behind a heavyweight abstraction, Drizzle lets you declare schemas in TypeScript and then either write relational queries (similar to an ORM) or SQL-like queries (similar to a query builder), both fully typed end to end. Its companion CLI, Drizzle Kit, handles migrations, and Drizzle Studio provides a GUI for browsing and editing data, giving teams a complete, serverless-ready toolkit without generated clients or Rust binaries.
What You Get
- A ~7.4kb, zero-runtime-dependency core library that stays tree-shakeable and works in serverless/edge runtimes
- Type-safe schema declarations that double as the source of truth for both migrations and query type inference
- Two query APIs in one library: a chained SQL-style builder and a relational-query API (
db.query.table.findMany()) - Drizzle Kit, a companion CLI for generating and applying SQL migrations from your TypeScript schema
- Drizzle Studio, a GUI for browsing and editing data across any supported database
- First-class drivers for PostgreSQL, MySQL, SQLite, and SingleStore, plus serverless-specific adapters for Neon, Turso, PlanetScale, Cloudflare D1, and Vercel Postgres
Common Use Cases
- Adding a typed data layer to a Next.js, Remix, or SvelteKit app without a code-generation build step
- Running database access from edge/serverless functions (Cloudflare Workers, Vercel Edge) where lightweight, dependency-free clients matter
- Migrating off a heavier ORM (Prisma, TypeORM) when teams want SQL-like control with full TypeScript inference
- Building internal tools or admin panels quickly using Drizzle Studio alongside the schema already defined for the app
Under The Hood
Architecture — drizzle-orm/src/index.ts re-exports the dialect-agnostic core: column/table builders (column-builder.ts, column.ts, table.ts), the branded-type system (entity.ts), and the SQL AST builder (sql/sql.ts, 722 lines). Each dialect (pg-core/, mysql-core/, sqlite-core/, singlestore-core/, gel-core/) implements its own column types and query builders on top of that shared AST — for example pg-core/query-builders/select.ts (1,346 lines) builds a Query object that is rendered through a BuildQueryConfig interface (escapeName/escapeParam/escapeString), which is how one query-builder API targets many SQL dialects. Driver adapters (node-postgres/, postgres-js/, neon-http/, libsql/, better-sqlite3/, bun-sqlite/, d1/, planetscale-serverless/, mysql2/, and more) each wrap one database client and adapt it to a common Session/QueryPromise interface (session.ts, query-promise.ts). Because the library is split across dozens of separately-published driver packages, instanceof checks are unreliable across module boundaries, so the codebase uses a symbol-based entityKind brand and an is() helper (entity.ts) pervasively instead.
Tech Stack — Pure TypeScript, published as dual ESM/CJS via a custom scripts/build.ts. The core drizzle-orm package declares zero runtime dependencies in package.json — all 29 database drivers and clients (pg, mysql2, better-sqlite3, @neondatabase/serverless, @libsql/client, and others) are optional peerDependencies, so consumers only install what they actually use. The repository is a pnpm + Turborepo monorepo (pnpm-workspace.yaml, turbo.json) housing sibling packages drizzle-kit (migrations CLI), drizzle-zod/drizzle-valibot/drizzle-arktype/drizzle-typebox (schema-validation bridges), and drizzle-seed. It targets every major JavaScript runtime — Node.js, Bun, Deno, Cloudflare Workers/D1, Vercel Edge, and React Native via op-sqlite/expo-sqlite adapters.
Code Quality — There are no unit test files co-located in drizzle-orm/src/, but the root-level integration-tests/ workspace contains 68 test files (run via Vitest against real database connections per dialect) plus a separate type-tests/ directory that performs compile-time type assertions to catch inferred query-type regressions — a pattern suited to a library whose main product is precise type inference. Error handling is centralized through a DrizzleError/DrizzleQueryError hierarchy (errors.ts) that preserves the original driver error on .cause. Naming and file layout are strikingly consistent across dialect implementations — pg-core/, mysql-core/, and sqlite-core/ mirror each other’s structure almost exactly, which keeps the cost of adding a new dialect low and the codebase easy to navigate once one dialect is understood.
API Design — A single call, drizzle(client, { schema }), returns a fully-typed db object usable immediately for both SQL-style chained queries (db.select().from(table).where(...)) and relational-style queries (db.query.table.findMany()), with no separate code-generation step — the TypeScript schema declaration is itself the source of type inference. A minimal schema.ts using pgTable(...)/sqliteTable(...) is enough to get full autocomplete on selects, inserts, joins, and relations. The trade-off is setup complexity: the 29-entry peerDependencies list means a new user has to correctly match a driver package to their database and runtime before anything works, and the per-driver README files scattered through src/ (postgres-js/README.md, kysely/README.md, etc.) reflect how much dialect/driver-specific knowledge the API surface still requires.
Used by 55 apps in this directory
agentic-inbox
AI Agents · Productivity
A self-hosted email client with an AI agent that reads your inbox, drafts replies automatically, and exposes full email operations over MCP — running entirely on Cloudflare Workers.
Amical
Note Taking · AI Assistants
Local-first AI dictation that understands your active app — private, offline, and built for speed.
Anarlog
Note Taking · AI Assistants · Productivity
Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.
BrowserOS
Browser · AI Assistants
The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.
Bubble Lab
Automation · AI Development
Open-core workflow engine for building AI-powered automations in TypeScript that run natively inside Slack — no context switching required.
Bun
Developer Tools
An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.
Cap
Team Chat · Video Conferencing
Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.
Cherry Studio
AI Assistants
All-in-one AI desktop client with 300+ assistants and multi-model support
cmux
Developer Tools · AI Development
A native, Ghostty-based macOS terminal with vertical tabs, agent-aware notifications, and a scriptable browser built for running many parallel AI coding agent sessions instead of juggling tmux panes.