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 distributed as two separate npm packages: the prisma-next CLI (a dev dependency used at build time) and a target facade such as @prisma-next/postgres (a runtime dependency). This page covers prerequisites, both installation paths, and how to configure the project manually if you prefer not to use the prisma-next init scaffold.

Prerequisites

Before installing, make sure your environment meets these requirements:
  • Node.js 24 LTS or newer. Prisma Next uses import ... with { type: 'json' } (JSON import attributes) and other Node.js 24 features.
  • pnpm (recommended) or npm, yarn, or bun. The CLI and all examples use pnpm.
  • PostgreSQL — a running Postgres instance accessible via a DATABASE_URL connection string. MongoDB support is available via @prisma-next/mongo (see below).

Install the CLI

Install prisma-next as a dev dependency. It provides the prisma-next binary used to emit contracts, manage the database, and run migrations.
npm install -D prisma-next
Confirm the install worked:
pnpm prisma-next --help

Install the target facade

Install @prisma-next/postgres as a regular (runtime) dependency. This single package includes the config helper, the Node.js runtime facade, the serverless facade, and all transitive type dependencies — you do not need to install adapter or driver packages separately.
npm install @prisma-next/postgres

Automated scaffold with prisma-next init

Run pnpm dlx prisma-next init to scaffold an entire project in one step. The init command prompts for your database target (PostgreSQL or MongoDB), your schema location, and your connection string. It then installs prisma-next and the appropriate facade, creates prisma-next.config.ts and a starter schema, and runs prisma-next contract emit automatically.
You can also run init without installing the CLI first:
pnpm dlx prisma-next init

Manual setup

If you prefer to configure the project yourself, follow these steps.

Create prisma-next.config.ts

Create prisma-next.config.ts at the root of your project. Use the defineConfig export from @prisma-next/postgres/config, which pre-wires the Postgres family, target, adapter, and driver — you only need to supply the schema path and connection options.
prisma-next.config.ts
import { defineConfig } from '@prisma-next/postgres/config'

export default defineConfig({
  contract: './prisma/schema.psl',
  db: { connection: process.env['DATABASE_URL']! },
})
Store your database URL in a .env file:
.env
DATABASE_URL=postgresql://user:pass@localhost:5432/mydb

Extension packs

To add an extension pack such as pgvector, install its package and register it in the config:
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']! },
  extensions: [pgvector],
})
When using @prisma-next/postgres/config’s simplified defineConfig, the option is named extensions. When using the full @prisma-next/cli/config-types defineConfig directly, the option is named extensionPacks.

Add a DATABASE_URL to your environment

The connection string follows the standard Postgres URI format:
postgresql://<user>:<password>@<host>:<port>/<database>
For local development, a typical value is:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/myapp

Emit the contract and initialize the database

With the config and schema in place, emit the contract and bootstrap the database:
pnpm prisma-next contract emit
pnpm prisma-next db init
contract emit writes contract.json and contract.d.ts to the output path set in your config. db init creates the tables described by the contract (additive only — existing tables are not modified).

MongoDB alternative

If you are targeting MongoDB instead of PostgreSQL, install @prisma-next/mongo in place of @prisma-next/postgres and use its defineConfig export:
prisma-next.config.ts
import { defineConfig } from '@prisma-next/mongo/config'

export default defineConfig({
  contract: './prisma/schema.psl',
  db: { connection: process.env['DATABASE_URL']! },
})
The rest of the workflow — emit, db init, queries — is identical. Refer to the MongoDB guide for target-specific differences.

Verify your installation

After setup, confirm everything is working:
# Confirm the CLI is available
pnpm prisma-next --version

# Re-emit the contract from your schema
pnpm prisma-next contract emit

# Verify the database matches the emitted contract
pnpm prisma-next db verify
If db verify exits cleanly, your environment is correctly set up and you are ready to write queries.

Next steps

Quickstart

Walk through the full workflow: schema, emit, db init, and first query.

CLI reference

Full reference for every prisma-next command and flag.

CLI configuration

Full reference for every option in prisma-next.config.ts.

Core concepts

Understand the contract-first model that powers Prisma Next.

Build docs developers (and LLMs) love