Skip to main content
The starting point for every Prisma Next project is defining your data model. Prisma Next supports two authoring modes — Prisma Schema Language (PSL) and a TypeScript builder API — that both produce the same deterministic contract.json artifact. Once emitted, that artifact drives query type safety, runtime verification, and migration planning without any further code generation.

Authoring modes

Prisma Schema Language uses a declarative, human-readable syntax. Models, fields, and relations are defined in a .psl file using familiar Prisma syntax.
After authoring, run the emit command to produce the contract artifacts:

The emit command

prisma-next contract emit reads your contract source (PSL or TypeScript) and produces two artifacts in your output directory:
The command:
  1. Loads the contract source (bundles TypeScript with esbuild; validates import allowlist for TS mode)
  2. Validates that the resulting object is pure data — no functions, no getters, JSON-serializable
  3. Canonicalizes the contract (lexicographic key ordering, normalized scalars)
  4. Computes storageHash, profileHash, and optional executionHash via SHA-256 over the canonical JSON
  5. Writes contract.json and generates contract.d.ts
The contract emit command does not connect to a database. You can run it without a driver configured.

What gets emitted

contract.json

The canonical JSON artifact contains everything needed to verify queries at runtime and plan migrations:
Do not edit contract.json by hand. The _generated warning header is there as a reminder.

contract.d.ts

The companion TypeScript declaration file exports branded types for every model and codec in your contract. Query DSL and ORM surfaces import from this file to give your queries fully-typed results:

How contractHash is computed

Prisma Next uses SHA-256 over the canonicalized contract JSON to produce the storageHash. Canonicalization rules include:
  • All object keys sorted lexicographically at every nesting level
  • Scalar values normalized (numbers, strings, booleans in standard forms)
  • Default expressions normalized (e.g. now() is always the same string)
  • Array ordering preserved where order is semantically meaningful
Because the same schema always produces the same canonical bytes, storageHash is stable across machines, operating systems, and Node.js versions. The runtime embeds this hash in every query plan and verifies it against the database marker before execution.

No-emit workflow

If you author your contract in TypeScript, you can skip the explicit emit step entirely during development. Types flow directly from the contract object through the DSL generics — no file needs to be written to disk.
In this mode the Vite (or esbuild/Next.js) plugin auto-emits contract.json whenever the contract module changes. CI still runs prisma-next contract emit explicitly to validate determinism before deployment.
PSL-first and TypeScript-first authoring produce identical storageHash values for the same schema. The canonical JSON representation is the same regardless of which authoring surface you use.