What problem does it solve?
Kysely eliminates the tedium and risk of writing database code without reliable TypeScript guarantees by keeping query inputs and results strongly typed end-to-end, from your schema to executed SQL.
Core Features & Use Cases
- Full Type Inference (Schema → Queries → Results): prevents common type mismatches by inferring the return shape from your table definitions and selected fields.
- Plain SQL with Raw Escape Hatch: supports complex SQL constructs (CTEs, window functions, subqueries) while still allowing targeted raw SQL with types when needed.
- Safe Migrations and Transactions: helps you evolve schemas with reversible up/down migrations and wrap multi-step operations in typed transactions.
Use it when you’re building a production-grade data layer in TypeScript, especially for complex querying and schema evolution where you want SQL control without ORM overhead (e.g., migrating an existing codebase, implementing advanced reporting queries, or adding transactional writes).
Quick Start
Use the kysely skill to generate a type-safe SELECT and INSERT flow for your database by defining your Database interface, creating a Kysely instance with the correct dialect/driver, and writing queries with execute to obtain correctly typed results.