Overview
Drizzle ORM is a modern TypeScript ORM designed to offer a type-safe and performant way to interact with SQL databases. Launched in 2022, Drizzle ORM distinguishes itself by providing an API that is described as close to raw SQL, aiming to reduce the abstraction layer often found in other ORMs while maintaining strong type inference and safety for TypeScript developers Drizzle ORM Get Started guide. This approach allows developers to write queries that feel familiar to SQL, but with the added benefits of TypeScript's static analysis, catching potential errors at compile time rather than runtime.
The framework targets developers who prioritize type safety and performance, especially in serverless or highly scalable environments where minimizing overhead is crucial. Drizzle ORM supports a range of popular SQL databases, including PostgreSQL, MySQL, and SQLite, and integrates well with various JavaScript runtimes like Node.js, Bun, and Deno Drizzle ORM supported databases. Its lightweight nature means it typically has a smaller bundle size and faster startup times compared to some more feature-rich ORMs, making it a suitable choice for applications where every millisecond and byte counts.
Drizzle ORM's design philosophy emphasizes a schema-first approach, where database schemas are defined using TypeScript, enabling seamless type generation for both the database schema and query results. This integration helps maintain consistency between the application code and the database structure. The ORM also provides Drizzle Kit, a companion tool for managing database migrations, schema generation, and introspection Drizzle Kit Quick Start. This tooling aims to streamline the development workflow, from defining models to deploying schema changes.
The ORM is particularly well-suited for projects that are built with a TypeScript-first mindset and require fine-grained control over SQL queries without sacrificing type safety. Its ability to generate types directly from the database schema and queries helps reduce boilerplate and improve developer experience. For teams migrating from raw SQL or seeking an ORM that doesn't hide the underlying database operations, Drizzle ORM offers a balance between abstraction and control.
Key features
- Type-Safe Query Builder: Offers a fluent API for constructing SQL queries with end-to-end type safety, ensuring that queries match the database schema and preventing common runtime errors Drizzle ORM Overview.
- Schema Definition in TypeScript: Define database schemas directly within TypeScript code, which Drizzle ORM uses to infer types for queries and results Drizzle ORM Schemas documentation.
- Lightweight and Performant: Designed with minimal overhead, contributing to smaller bundle sizes and faster execution, which is beneficial for serverless functions and performance-critical applications.
- Multi-Database Support: Compatible with PostgreSQL, MySQL, and SQLite, providing flexibility across different database environments Drizzle ORM Get Started guide.
- Drizzle Kit for Migrations: Includes a command-line tool, Drizzle Kit, for managing database migrations, schema generation, and introspection, simplifying schema evolution Drizzle Kit Quick Start.
- Relational Query Capabilities: Supports defining and querying relationships between tables, allowing for complex data retrieval with type safety Drizzle ORM Relations documentation.
- SQL-like API: The API is designed to be intuitive for developers familiar with SQL, providing a thin layer over raw SQL operations.
- Integration with JavaScript Runtimes: Works with Node.js, Bun, and Deno, offering broad compatibility for modern JavaScript backends.
Pricing
Drizzle ORM is a free and open-source project. Its core products, Drizzle ORM and Drizzle Kit, are available without licensing fees.
| Product/Service | Pricing Model | Details |
|---|---|---|
| Drizzle ORM | Free and Open Source | Full access to the ORM library, including all features and database drivers. |
| Drizzle Kit | Free and Open Source | Command-line tool for schema management, migrations, and introspection. |
Pricing as of 2026-06-13. For the most current information, refer to the Drizzle ORM homepage.
Common integrations
- Next.js: Drizzle ORM can be integrated into Next.js applications for full-stack type-safe data access Drizzle ORM Next.js Quick Start.
- React.js: Used in conjunction with React frameworks to manage data interactions in web applications React documentation.
- PostgreSQL: Connects to PostgreSQL databases using various drivers like
pgornode-postgresDrizzle ORM PostgreSQL Quick Start. - MySQL: Supports MySQL databases with connectors like
mysql2Drizzle ORM MySQL Quick Start. - SQLite: Integrates with SQLite databases, often used for local development or embedded databases Drizzle ORM SQLite Quick Start.
- Vercel Postgres: Specifically designed for seamless integration with Vercel's managed PostgreSQL service Drizzle ORM Vercel Postgres Quick Start.
- PlanetScale: Compatible with PlanetScale's serverless MySQL platform Drizzle ORM PlanetScale Quick Start.
- Neon: Integrates with Neon's serverless PostgreSQL Drizzle ORM Neon Quick Start.
Alternatives
- Prisma: A widely used ORM for Node.js and TypeScript, known for its strong type safety, declarative schema, and powerful data access layer Prisma homepage.
- Kysely: A type-safe SQL query builder for TypeScript, offering a programmatic way to build SQL queries with strong type inference, often chosen for its minimal abstraction over SQL Kysely homepage.
- TypeORM: An ORM that supports multiple databases and provides features like Active Record and Data Mapper patterns, widely used in enterprise-level Node.js applications TypeORM homepage.
- Sequelize: A promise-based Node.js ORM for Postgres, MySQL, SQLite and SQL Server, offering comprehensive features for database interaction and migrations Sequelize homepage.
- Knex.js: A SQL query builder for Node.js, offering a flexible and programmatic way to construct SQL queries across various databases, often used as a foundation for more opinionated ORMs Knex.js homepage.
Getting started
To get started with Drizzle ORM, you typically define your schema, create a Drizzle instance, and then execute queries. This example demonstrates setting up a simple SQLite database with Drizzle ORM and performing an insert and select operation.
// 1. Install Drizzle ORM and a database driver (e.g., better-sqlite3)
// npm install drizzle-orm better-sqlite3
// npm install -D drizzle-kit
import { drizzle } from 'drizzle-orm/better-sqlite3';
import Database from 'better-sqlite3';
import { sql } from 'drizzle-orm';
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
// 2. Define your schema
export const users = sqliteTable('users', {
id: integer('id', { mode: 'number' }).primaryKey({ autoIncrement: true }),
name: text('name').notNull(),
email: text('email').notNull().unique(),
});
// 3. Initialize the database client and Drizzle ORM
const sqlite = new Database('sqlite.db');
const db = drizzle(sqlite);
async function runDrizzleExample() {
// 4. (Optional) Run migrations using Drizzle Kit or raw SQL for initial setup
// For a real project, use Drizzle Kit CLI for migrations.
// Example raw SQL for initial table creation:
await db.run(sql`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT NOT NULL UNIQUE
);
`);
// 5. Insert data
console.log('Inserting new user...');
const insertedUser = await db.insert(users).values({ name: 'Alice', email: '[email protected]' }).returning();
console.log('Inserted user:', insertedUser);
// 6. Select data
console.log('Fetching all users...');
const allUsers = await db.select().from(users);
console.log('All users:', allUsers);
// 7. Select a specific user by email
console.log('Fetching user by email...');
const userByEmail = await db.select().from(users).where(sql`${users.email} = '[email protected]'`);
console.log('User by email:', userByEmail);
sqlite.close();
}
runDrizzleExample().catch(console.error);