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 contract emit reads your TypeScript-authored contract from config.contract, validates its purity, and writes two canonical artifacts to disk: contract.json (the serialized contract with metadata) and contract.d.ts (the corresponding TypeScript type declarations). No database connection is required — this command is fully offline.

Synopsis

prisma-next contract emit [--config <path>] [--json] [-q] [-v] [-vv] [--color|--no-color]

Options

--config
string
Path to prisma-next.config.ts. Accepts relative or absolute paths. Defaults to ./prisma-next.config.ts in the current working directory if the file is present. The CLI does not search upward.
--json
boolean
Emit a JSON result envelope to stdout instead of the default human-readable TTY output. Use this flag in build pipelines and editor integrations.
-q, --quiet
boolean
Suppress all output except errors.
-v, --verbose
boolean
Print debug information and timing data.
-vv, --trace
boolean
Print deep internal trace output including stack traces. Intended for debugging the CLI itself.
--color / --no-color
boolean
Force-enable or force-disable ANSI color in output. By default, color is enabled when stdout is a TTY.

Config file requirements

contract emit does not connect to a database, so a driver is not required in your config. The minimum required fields are family, target, adapter, and contract.
prisma-next.config.ts
import { defineConfig } from '@prisma-next/cli/config-types';
import { typescriptContract } from '@prisma-next/sql-contract-ts/config-types';
import postgresAdapter from '@prisma-next/adapter-postgres/control';
import postgres from '@prisma-next/target-postgres/control';
import sql from '@prisma-next/family-sql/control';
import { contract } from './prisma/contract';

export default defineConfig({
  family: sql,
  target: postgres,
  adapter: postgresAdapter,
  extensionPacks: [],
  contract: typescriptContract(contract, 'src/prisma/contract.json'),
});
The second argument to typescriptContract sets contract.output — the path where contract.json is written. contract.d.ts is always co-located with contract.json. If omitted, contract.output defaults to src/prisma/contract.json.

Examples

prisma-next contract emit

Output format

TTY (default)

When stdout is a TTY, the command prints a human-readable summary:
✔ Contract emitted
  contract.json:  src/prisma/contract.json
  contract.d.ts:  src/prisma/contract.d.ts
  storageHash:    sha256:abc123...
  Total time:     42ms

JSON (--json)

With --json, the command prints a single JSON object and exits:
{
  "ok": true,
  "summary": "Contract emitted",
  "contract": {
    "jsonPath": "/path/to/src/prisma/contract.json",
    "dtsPath": "/path/to/src/prisma/contract.d.ts",
    "storageHash": "sha256:abc123..."
  },
  "meta": {
    "configPath": "/path/to/prisma-next.config.ts"
  },
  "timings": {
    "total": 42
  }
}

Emitted artifacts

contract.json

A JSON serialization of the canonicalized contract. The file includes a _generated metadata field indicating it is a generated artifact and must not be edited manually. The _generated field is excluded from canonicalization and hashing so it does not affect storageHash or profileHash.

contract.d.ts

TypeScript type declarations derived from contract.json. The file opens with a warning header comment marking it as generated. Import from this file to get precise literal types for use with validateContract<Contract>(json) — JSON imports alone lose literal types.
Do not edit contract.json or contract.d.ts by hand. Both files are regenerated on every contract emit run. Commit them to version control so other commands (db verify, db sign, db init, migration plan) can locate the artifacts.

Canonical emit path

Both this CLI command and the @prisma-next/vite-plugin-contract-emit Vite plugin route through the same executeContractEmit function. If you need to extend emission behavior, extend ContractEmitOptions / ContractEmitResult and update executeContractEmit directly — do not re-implement the load → emit → publish flow in a new caller.
Concurrent calls for the same output path are serialized FIFO; concurrent calls for distinct output paths run in parallel. Long-lived hosts (Vite dev server, watch CLIs) should call disposeEmitQueue on shutdown to avoid leaking per-output queue state.

Build docs developers (and LLMs) love