prisma-next CLI command reads a prisma-next.config.ts file to understand your database family, target, adapter, contract location, and optional connection details. The config is a TypeScript module that exports a default value produced by defineConfig. There are two ways to write it: the simplified facade approach (recommended for most projects) and the full explicit approach for advanced wiring.
Approaches
- Simplified (recommended)
- Full explicit
The This is the shortest path to a working config and is what
@prisma-next/postgres/config package exposes a defineConfig helper that pre-wires the SQL family, Postgres target, adapter, and driver. You only need to provide a contract path and, optionally, a database connection:prisma-next init scaffolds for Postgres projects.Required fields
The following fields must be present in any valid config (the simplified facade sets them for you):Optional fields
Commands that require a database connection will exit with error code
PN-CLI-4010 if driver is missing from the config, and PN-CLI-4005 if no connection URL is available from either db.connection or --db.Contract providers
Thecontract field takes a provider value rather than a plain path. Two providers ship out of the box:
typescriptContract — TypeScript-authored contracts
Use when your contract is authored in TypeScript and imported as a module:
prismaContract — PSL-authored contracts
Use when your contract is authored in Prisma Schema Language (.prisma files):
contract.d.ts is always co-located with contract.json and derived automatically from contract.output — you do not configure it separately.
Extension packs and wiring validation
When your contract declares extension packs, the CLI performs wiring validation before running anydb command that touches the database. It checks that:
contract.targetFamilymatchesconfig.family.familyIdcontract.targetmatchesconfig.target.targetId- Every extension pack listed in the contract is present in
config.extensionPacks(matched by descriptorid)
config.extensionPacks and re-run.
Commands that enforce wiring validation: db verify, db sign, db init, db update.
Commands that do not need a driver
prisma-next contract emit does not connect to the database, so driver and db.connection are not required:
Config validation
defineConfig validates and normalizes the config at load time using Arktype schemas. Validation failures produce actionable error messages. Normalization applies default values — for example, contract.output defaults to 'src/prisma/contract.json' when not specified.
Full example: emit-only config
1
Install the CLI and facade
2
Write prisma-next.config.ts
3
Emit your contract
src/prisma/contract.json and src/prisma/contract.d.ts.4
Add a driver for database commands
Update your config to include a connection URL. The simplified facade picks up the driver automatically when Now commands like
db.connection is set:prisma-next db verify and prisma-next db sign will work.