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, built around a contract-first model. Instead of generating an opaque runtime client, Prisma Next emits a deterministic contract.json and TypeScript types that describe your database schema. These artifacts become the single source of truth for query authoring, runtime verification, and tooling — including AI-assisted workflows.
Pre-1.0 — not production ready. Prisma Next is an active engineering preview. Expect breaking changes between minor versions; only the latest minor receives security fixes. Prisma 7 remains the recommended version for production applications.

The problem Prisma Next solves

Traditional ORMs — including Prisma ORM — generate an executable runtime client from your schema. That client is opaque, hard to diff, and tightly coupled to the schema at generation time. Detecting drift between the generated client and the live database requires running queries; there is no lightweight way to verify the two are in sync. Prisma Next separates concerns: schema authoring produces a data contract (JSON + TypeScript types), and query execution is handled by a composable DSL that is verified against that contract at runtime. The contract is a plain JSON file — diffable, hashable, and readable by humans and machines alike.

How Prisma Next differs from Prisma 7

FeaturePrisma ORM (v7)Prisma Next
Schema modelCodegen for runtime clientContract IR + TypeScript types
Code generationHeavy, runtime-boundMinimal, build-time only
Query interfaceGenerated methodsComposable DSL
Machine readabilityOpaque client codeStructured IR JSON
VerificationNoneContract hash + runtime checks
ExtensibilityMonolithic clientPlugin and hook system
Migration logicSequential scriptsContract-based, deterministic
Prisma ORM workflow:
  1. Write schema.prisma
  2. Run prisma generate — generates executable client code
  3. Call generated methods: prisma.user.findMany()
Prisma Next workflow:
  1. Write schema.psl
  2. Run prisma-next contract emit — generates lightweight types + contract JSON
  3. Query using the composable DSL: db.sql.user.select(...).build()

The three-step contract-first workflow

Every Prisma Next project follows the same three steps.
1

Define your schema

Write your data model in PSL (Prisma Schema Language). The schema is the authoritative description of your database structure.
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

  user User @relation(fields: [userId], references: [id])
}
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
The contract includes a contractHash that cryptographically ties all artifacts to a specific schema version. The runtime uses this hash to detect drift before any query runs.
3

Query with full type safety

Import the facade package for your database target, pass the contract, and query using either the SQL DSL (db.sql) or the ORM client (db.orm).
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 })
queries.ts
// SQL DSL — composable, lower-level control
const plan = db.sql.user
  .select('id', 'email')
  .limit(10)
  .build()

// ORM client — fluent model-level access
const posts = await db.orm.Post
  .where((p) => p.userId.eq(userId))
  .include('user')
  .all()

Two query APIs

Prisma Next ships two query APIs that share the same contract and type system. db.sql — SQL DSL: A composable, type-safe query plan builder that gives you precise control over what SQL is generated. Queries are built as explicit plan objects that can be inspected, logged, and verified before execution. db.orm — ORM client: A fluent model-level API with where, include, select, and orderBy composition. Results are fully typed based on your contract. The ORM client builds on the same plan infrastructure as the SQL DSL, so it inherits all runtime verification guarantees.

Extensible by design

Prisma Next supports extension packs — optional packages that add new schema attributes, query operators, codecs, and migration support. Extension packs are registered in prisma-next.config.ts:
prisma-next.config.ts
import { defineConfig } from '@prisma-next/postgres/config'
import pgvector from '@prisma-next/extension-pgvector/control'

export default defineConfig({
  contract: './prisma/schema.psl',
  db: { connection: process.env['DATABASE_URL']! },
  extensionPacks: [pgvector],
})
Once registered, the extension’s schema attributes and query operators become available with full type safety — no changes to the core library required.

What’s next

Quickstart

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

Installation

Install the CLI and Postgres facade package step by step.

Core concepts

Deep dive into the contract-first model, schema emission, and runtime verification.

CLI reference

Full reference for every prisma-next command.

Build docs developers (and LLMs) love