Home

Kysely

Kysely is a type-safe SQL query builder for TypeScript and Node.js. It provides a fluent, composable API for constructing SQL queries with compile-time type safety against a user-defined database schema. By defining a database interface that describes tables and their row shapes, developers receive strongly typed query results and can catch column or join mismatches during development rather than at runtime.

The library is database-agnostic in its API and relies on drivers or dialect adapters to communicate with

Key features include support for typical SQL statements such as select queries with joins, where clauses, group

Usage typically involves defining a DB interface that maps table names to their row types, creating a

specific
databases.
It
supports
popular
SQL
engines
through
drivers,
enabling
work
with
PostgreSQL,
MySQL,
SQLite,
and
related
systems
by
wiring
a
corresponding
driver
to
the
Kysely
instance.
The
same
query
construction
API
remains
consistent
across
dialects,
while
the
underlying
driver
handles
database-specific
behavior.
by
and
order
by,
as
well
as
inserts,
updates,
and
deletes.
It
also
provides
capabilities
for
transactions,
prepared
statements,
and
raw
SQL
through
a
typed
interface.
Result
types
are
inferred
from
the
defined
database
schema,
helping
ensure
that
code
accessing
rows
uses
correct
column
names
and
types.
Kysely
instance
bound
to
a
specific
driver,
and
then
composing
queries
using
the
type-safe
API.
Kysely
does
not
include
a
built-in
schema
migration
system,
so
developers
commonly
use
external
migration
tooling
alongside
the
library.