Skip to main content
Every 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

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

The contract 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 any db command that touches the database. It checks that:
  • contract.targetFamily matches config.family.familyId
  • contract.target matches config.target.targetId
  • Every extension pack listed in the contract is present in config.extensionPacks (matched by descriptor id)
If validation fails, the command exits with a structured error describing the mismatch. To fix it, add the required extension pack descriptor to config.extensionPacks and re-run. Commands that enforce wiring validation: db verify, db sign, db init, db update.
A mismatch between your emitted contract and the descriptors in your config will prevent database commands from running. Always re-emit (prisma-next contract emit) after changing extension packs, then update the extensionPacks array in your config to match.

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:
This is useful in CI jobs that only emit the contract artifact without connecting to a live database.

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

This writes 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 db.connection is set:
Now commands like prisma-next db verify and prisma-next db sign will work.