What is Kysely?
masterKysely (pronounced “Key-Seh-Lee”) is a type-safe and autocompletion-friendly TypeScript SQL query builder. It is inspired by Knex.js and is designed to ensure that you only refer to tables and columns that are visible to the specific part of the query you are writing.
Key features include:
- Type Safety: Result types only contain the selected columns with correct types and aliases.
- Autocompletion: Full autocompletion for tables, columns, aliases, and subqueries.
- Advanced Inference: Automatically infers column names, aliases, and types from selected subqueries, joined subqueries,
withstatements, and more. - Environment Agnostic: While primarily developed for Node.js, it runs on Deno, Bun, Cloudflare Workers, and web browsers.
If you encounter situations that cannot be typed at compile time, Kysely provides escape hatches such as the sql template tag and DynamicModule.