prisma-kysely
A Prisma generator that emits fully typed Kysely database definitions from your Prisma schema.
Repository Health
Technical Analysis
prisma-kysely is a Prisma generator that lets you keep using Prisma’s schema language and migration workflow while querying your database with Kysely, the type-safe SQL query builder. During prisma generate it reads your schema and emits a set of Kysely-compatible TypeScript types, so your hand-written SQL stays fully typed and in sync with the schema.
It supports multiple SQL dialects, configurable type overrides, enum and JSON handling, and Cloudflare D1, making it a popular bridge for teams that want Prisma’s ergonomics for modeling and migrations but Kysely’s control and performance for queries.
What You Get
- A
prisma-kyselygenerator block you add to yourschema.prisma - Generated Kysely
Databaseinterface and per-table type definitions - Configurable type overrides for columns, enums, and JSON fields
- Support for multiple SQL dialects including Cloudflare D1
- A single schema as the source of truth for both migrations and query types
Common Use Cases
- Using Prisma for schema modeling and migrations while running queries through Kysely
- Getting fully typed raw-SQL query building without maintaining hand-written types
- Generating database types for edge runtimes and Cloudflare D1 from a Prisma schema
Under The Hood
Architecture - The generator entry point in src/bin.ts registers with @prisma/generator-helper; src/generator.ts walks the parsed schema (via @mrleebo/prisma-ast and @prisma/internals) and, with helpers under src/helpers and src/utils, maps each model, field, and enum onto a Kysely type, emitting a TypeScript file. Dialect-specific behavior is exercised by src/dialectTests.
Tech Stack - Written in TypeScript and distributed as a CLI binary (dist/bin.js). It depends on @prisma/generator-helper, @prisma/internals, @mrleebo/prisma-ast, typescript, and zod for validating generator configuration.
Code Quality - The codebase includes a __test__ suite plus dedicated dialect test fixtures, uses zod to validate options, and keeps type-mapping logic separated into small helper modules. Naming is descriptive and the transformation pipeline is easy to follow.
API Design - Configuration is declarative: you add a generator block to schema.prisma with a handful of options (output path, dialect, type overrides). There is no imperative API to learn — the tool runs as part of the standard prisma generate flow, so adoption is a few lines of schema config.
Used by 2 apps in this directory
Cal.diy
Scheduling
The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.
Documenso
Digital Signiture
Self-hosted, open-source DocuSign alternative with legally binding PDF signatures, multi-party workflows, and a full REST and tRPC API.