From 885a0e75789140a8a3f197e7ffb5abd0c1cbcbdc Mon Sep 17 00:00:00 2001 From: Igal Klebanov Date: Sat, 9 May 2026 09:53:36 +0300 Subject: [PATCH 1/2] Document Kysely support for PGlite Added Kysely section with installation and usage instructions for PGlite. --- docs/docs/orm-support.md | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/docs/docs/orm-support.md b/docs/docs/orm-support.md index 678bec263..511592776 100644 --- a/docs/docs/orm-support.md +++ b/docs/docs/orm-support.md @@ -80,6 +80,57 @@ await db.select().from(...); See the [Drizzle documentation](https://orm.drizzle.team/docs/connect-pglite) for more details. +## Kysely + +[Kysely](https://kysely.dev) is a **type-safe** TypeScript SQL query builder +with support for many databases, including PGlite. Features include: + +- End-to-end type-safety and autocompletion +- Composable query builder for `SELECT` / `INSERT` / `UPDATE` / `DELETE` / `MERGE` +- Schema builder and migrator +- Pluggable dialect and plugin APIs +- Built-in PGlite dialect (since Kysely `0.29.0`) + +To use Kysely with PGlite, install `kysely` (>= 0.29) alongside `@electric-sql/pglite`: + +```bash +npm i @electric-sql/pglite kysely +``` + +Then create a Kysely instance using the built-in `PGliteDialect`: + +```ts +import { PGlite } from '@electric-sql/pglite' +import { Kysely, PGliteDialect } from 'kysely' + +// See https://kysely.dev/docs/generating-types +interface Database { + person: { + id: string + } +} + +const db = new Kysely({ + dialect: new PGliteDialect({ + pglite: new PGlite(), + }), +}) + +const people = await db.selectFrom('person').selectAll().execute() +``` + +`pglite` can also be a function (sync or async), in which case the PGlite +instance is created lazily the first time a query runs: + +```ts +new PGliteDialect({ + pglite: () => new PGlite('./path/to/pgdata'), +}) +``` + +See the [Kysely documentation](https://kysely.dev/docs/getting-started?dialect=pglite) +for more details. + ## Knex.js [Knex](https://knexjs.org/) is a stable, reliable Query Builder for various From 2e385a8d89bc8cfc89eb4c156fcb04eabed92c69 Mon Sep 17 00:00:00 2001 From: Igal Klebanov Date: Sun, 10 May 2026 22:48:26 +0300 Subject: [PATCH 2/2] ... --- docs/docs/orm-support.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/docs/orm-support.md b/docs/docs/orm-support.md index 511592776..a33846929 100644 --- a/docs/docs/orm-support.md +++ b/docs/docs/orm-support.md @@ -82,13 +82,13 @@ for more details. ## Kysely -[Kysely](https://kysely.dev) is a **type-safe** TypeScript SQL query builder +[Kysely](https://kysely.dev) is a **type-safe** TypeScript SQL query builder with support for many databases, including PGlite. Features include: - End-to-end type-safety and autocompletion -- Composable query builder for `SELECT` / `INSERT` / `UPDATE` / `DELETE` / `MERGE` -- Schema builder and migrator -- Pluggable dialect and plugin APIs +- Composable, predictable, escape-rich, fluent API. +- Cancellable, pluggable, hookable. +- Migrations and DDL builders too. - Built-in PGlite dialect (since Kysely `0.29.0`) To use Kysely with PGlite, install `kysely` (>= 0.29) alongside `@electric-sql/pglite`: @@ -110,7 +110,7 @@ interface Database { } } -const db = new Kysely({ +const db = new Kysely({ dialect: new PGliteDialect({ pglite: new PGlite(), }), @@ -128,7 +128,7 @@ new PGliteDialect({ }) ``` -See the [Kysely documentation](https://kysely.dev/docs/getting-started?dialect=pglite) +See the [Kysely documentation](https://kysely.dev/docs/getting-started?dialect=pglite) for more details. ## Knex.js