npmdrizzle-ormv0.33.0
npmIntermediate

drizzle-orm

Lightweight TypeScript ORM with SQL-first design, zero magic, and edge-runtime support.

ormtypescriptsqldatabaseedge
The Problem

Prisma's generated client adds bundle weight and requires a sidecar query engine. You want type-safe SQL queries that are transparent (you can see the SQL), work at the edge, and don't have a heavy codegen step.

Mental Model

Drizzle is a thin TypeScript layer over SQL. You define tables as TypeScript objects, and queries look almost like SQL. `db.select().from(users).where(eq(users.id, 1))` compiles to `SELECT * FROM users WHERE id = 1`. No magic, no query engine โ€” just your DB driver.

60-second start

Define a schema and query it

npm install drizzle-orm pg
npm install -D drizzle-kit @types/pg
import { pgTable, serial, text, integer } from 'drizzle-orm/pg-core'

export const users = pgTable('users', {
  id: serial('id').primaryKey(),
  name: text('name').notNull(),
  age: integer('age'),
})
import { drizzle } from 'drizzle-orm/node-postgres'
import { Pool } from 'pg'
import { users } from './schema'
import { eq } from 'drizzle-orm'

const pool = new Pool({ connectionString: process.env.DATABASE_URL })
const db = drizzle(pool)

const result = await db.select().from(users).where(eq(users.id, 1))

Use it when

Edge runtimes (Cloudflare Workers, Vercel Edge), projects where you want full SQL control with types, lighter bundle size than Prisma, serverless environments.

Skip it when

If you prefer Prisma's schema-first DX and Studio. Complex ORM features like polymorphism. Teams more comfortable with ActiveRecord-style ORMs.

Alternatives
prismaMore DX polish, visual Studio, better for traditional Node.js backends.
kyselyEven more SQL-first, no schema definition layer, just a type-safe query builder.
typeormDecorator-based, more features but heavier and less type-safe.

Ready to explore the full API?

See every class, function, and relationship in an interactive graph.