Prisma

Next-generation TypeScript ORM — schema-first, auto-generated type-safe client, and Prisma Studio for data browsing.

TypeScript freemium Open Source data since 2016

Prisma generates a fully type-safe database client from your schema file — every query is typed based on your exact data model. Prisma Migrate handles schema migrations, Prisma Studio provides a visual data browser, and Prisma Accelerate adds connection pooling and query caching. It is the most popular ORM in the TypeScript ecosystem, widely used with Next.js, Express, and NestJS.

Quick start

npm install prisma @prisma/client
npx prisma init --datasource-provider postgresql
// prisma/schema.prisma
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

model Post {
  id        Int      @id @default(autoincrement())
  title     String
  body      String
  published Boolean  @default(false)
  author    User     @relation(fields: [authorId], references: [id])
  authorId  Int
  createdAt DateTime @default(now())
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
  posts Post[]
}
npx prisma migrate dev --name init
npx prisma generate
// src/db.ts
import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

// Fully typed — IDE knows the shape of every result
const posts = await prisma.post.findMany({
  where: { published: true },
  include: { author: true },
  orderBy: { createdAt: 'desc' },
})

const newPost = await prisma.post.create({
  data: {
    title: 'Hello Prisma',
    body: 'Type-safe database access.',
    author: { connect: { email: 'user@example.com' } },
  },
})

When to use

Prisma is the default ORM choice for TypeScript Node.js projects. Its schema-first approach and generated types eliminate a whole class of runtime bugs. Prisma Studio makes database exploration easy during development. For teams that prefer writing SQL directly with TypeScript safety, Drizzle ORM is a lighter alternative. For Python projects, SQLAlchemy is the equivalent.

// features

  • Schema-first — define your models in `schema.prisma`, generate a typed client
  • Auto-generated TypeScript types for every model and query
  • Prisma Migrate — SQL migrations from schema changes
  • Prisma Studio — visual data browser for your database
  • Prisma Accelerate — connection pooling and global query caching
  • Nested writes and transactions for complex operations
  • Supports PostgreSQL, MySQL, SQLite, MongoDB, SQL Server, CockroachDB
  • Raw SQL via `prisma.$queryRaw` when you need full control

// installation

npm npm install prisma @prisma/client && npx prisma init
yarn yarn add prisma @prisma/client && yarn prisma init

// tags

ormdatabasetypescriptpostgresqlmysqlsqliteschematype-safe
Something wrong? Edit this entry on GitHub.
✏ Edit on GitHub