This guide walks you through the full Prisma Next workflow end to end: installing packages, writing a schema, emitting a contract, initializing the database, and running queries using both the SQL DSL and the ORM client. You need Node.js 24+, pnpm, and a running PostgreSQL database to follow along.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.
Install packages
Install the
prisma-next CLI as a dev dependency and the @prisma-next/postgres facade as a runtime dependency.Create prisma-next.config.ts
Create a The
prisma-next.config.ts file at the root of your project. This file tells the CLI where your schema lives, how to connect to the database, and which extension packs to load.prisma-next.config.ts
defineConfig export from @prisma-next/postgres/config pre-wires all Postgres internals (family, target, adapter, driver). You only need to supply your schema path and connection string.Add your database URL to a .env file:.env
Define a schema
Create a
prisma/ directory and add a schema.psl file. The schema uses PSL (Prisma Schema Language) — the same language as Prisma ORM.prisma/schema.psl
The
// use prisma-next comment at the top of the file marks it as a Prisma Next schema. It is required.Emit the contract
Run The output path is configured via
prisma-next contract emit to generate contract.json and contract.d.ts from your schema. These two artifacts — not executable code — are the output of the build step.config.contract in prisma-next.config.ts. After emission you will find two files:contract.json— the runtime contract, consumed by the Postgres facadecontract.d.ts— TypeScript types for full autocompletion and safety
contractHash inside contract.json is used by the runtime to verify the database is in sync with the schema before any query runs.Initialize the database
Run For subsequent schema changes, use
prisma-next db init to create the tables described by the emitted contract. This command is additive only — it creates what is missing and leaves existing tables untouched.prisma-next db update (which also handles destructive operations) or the full migration workflow with prisma-next migration plan and prisma-next migration apply.Write and run your first query
Create a Now write queries using either the SQL DSL or the ORM client:Run your script with:The runtime verifies the
src/prisma/db.ts file that initializes the Postgres client with your emitted contract:src/prisma/db.ts
contractHash against the database before executing any query. If the database schema has drifted from the emitted contract, you will see a structured error with a stable code and a suggested fix rather than a silent data mismatch.Next steps
ORM client guide
Learn the full ORM client API: filters, includes, pagination, aggregations, and upserts.
SQL DSL guide
Master the SQL plan builder for lower-level query control and advanced use cases.
Migrations guide
Plan, apply, and verify schema migrations across environments.
CLI reference
Full reference for every
prisma-next command and configuration option.