Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/prisma/prisma-next/llms.txt

Use this file to discover all available pages before exploring further.

Prisma Next is a ground-up TypeScript rewrite of Prisma ORM, designed for composability, extensibility, and AI-assisted workflows. Instead of generating an opaque runtime client, Prisma Next emits a deterministic contract.json and TypeScript types that serve as a stable, machine-readable contract between your schema and your queries.
Pre-1.0 — not production ready. Prisma Next is an active engineering preview. Expect breaking changes between minor versions. Prisma 7 remains the recommended version for production applications.

Quickstart

Go from schema to your first type-safe query in minutes.

Installation

Install prisma-next and the Postgres facade package.

Core concepts

Understand the contract-first model that powers Prisma Next.

CLI reference

Full reference for every prisma-next command.

How it works

Prisma Next follows a three-step contract-first workflow:
1

Define your schema

Write your data model in PSL (Prisma Schema Language) or TypeScript builders.
schema.psl
model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
}

model Post {
  id      Int    @id @default(autoincrement())
  title   String
  userId  Int
}
2

Emit the contract

Run prisma-next contract emit to produce a deterministic contract.json and contract.d.ts. No executable code is generated — only data and types.
prisma-next contract emit
# Generates: .prisma/contract.json + .prisma/contract.d.ts
3

Query with full type safety

Import the facade package and query using the SQL DSL or ORM client. The runtime verifies the contract hash against the database before any query runs.
db.ts
import postgres from '@prisma-next/postgres/runtime'
import type { Contract } from './.prisma/contract.d'
import contractJson from './.prisma/contract.json' with { type: 'json' }

export const db = postgres<Contract>({ contractJson })

// SQL DSL
const users = await db.sql.user
  .select('id', 'email')
  .limit(10)
  .build()

// ORM client
const posts = await db.orm.Post
  .where((p) => p.userId.eq(userId))
  .include('author')
  .all()

Key features

Contract-first design

Schema emits a deterministic contract.json + TypeScript types. No generated runtime client — just data and types.

Two query APIs

Fluent ORM client for model-level access and a composable SQL DSL for lower-level control. Both are fully type-safe.

Runtime verification

Cryptographic hash checks detect schema drift before any query runs, catching mismatches at startup.

Extension packs

Add pgvector, PostGIS, CipherStash, and more without touching core. Each pack contributes codecs, operations, and migration support.

Serverless-ready

Dedicated per-request facade for Cloudflare Workers, AWS Lambda, Vercel Edge, Deno Deploy, and Bun.

Migration system

Contract-to-contract migration graph with planner, runner, preflight verification, and multi-environment refs.

Build docs developers (and LLMs) love