Prisma 8 extension
arktype-json
JSON columns validated by an arktype schema and typed end to end.
By PrismaPostgreSQL
What it does
Declare a jsonb column from an arktype Type. The emitted contract.d.ts renders the column as the schema's TypeScript shape, and the runtime validates every value it decodes against the same schema.
Register it in the config
prisma.config.ts
import { definePrismaConfig } from 'prisma/config';
import arktypeJson from '@prisma/orm-extension-arktype-json/control';
import { defineConfig as ormConfig } from '@prisma/orm-postgres/config';
export default definePrismaConfig({
orm: ormConfig({
contract: './src/prisma/contract.prisma',
extensions: [arktypeJson],
db: {
connection: process.env['DATABASE_URL']!,
},
}),
});Register it on the client
src/prisma/db.ts
import arktypeJson from '@prisma/orm-extension-arktype-json/runtime';
import postgres from '@prisma/orm-postgres/runtime';
import type { Contract } from './contract.d';
import contractJson from './contract.json' with { type: 'json' };
export const db = postgres<Contract>({
contractJson,
url: process.env['DATABASE_URL']!,
extensions: [arktypeJson],
});Then run npx prisma@latest db init, or db update on an existing database. The extension ships its own migration for anything the database needs installed. Full walkthrough in the extensions docs.
