Registry / database / kysely-pg-client

kysely-pg-client

JSON →
library0.1.14jsnpmunverified

A Kysely dialect for PostgreSQL that uses a single `pg.Client` connection instead of a connection pool. Version 0.1.14, actively maintained. Designed for serverless environments to avoid pool overhead, but the README advises using Kysely's built-in `PostgresDialect` with `max: 1` instead for better compatibility with libraries like Lucia. Tested against Kysely's own test suite for reliability.

npm install kysely-pg-client
INSTALL
IMPORT
SIG · KYSELY-PG-CLIENT
K
kysely-pg-client
databasejavascriptv0.1.14
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PostgresClientDialect
import { PostgresClientDialect } from 'kysely-pg-client'
import PostgresClientDialect from 'kysely-pg-client'
Package exports only this named symbol; no default export.
PostgresClientDialectConfig
import { PostgresClientDialectConfig } from 'kysely-pg-client'
Type import available; can be used as: import type { PostgresClientDialectConfig } from 'kysely-pg-client'.
Kysely
import { Kysely } from 'kysely'
import Kysely from 'kysely'
Kysely is a named export from Kysely package, not default.

Shows how to create a Kysely instance with PostgresClientDialect using a single Client connection.

import { Client } from 'pg'; import { Kysely } from 'kysely'; import { PostgresClientDialect } from 'kysely-pg-client'; interface Database { person: { id: Generated<number>; name: string; }; } const db = new Kysely<Database>({ dialect: new PostgresClientDialect({ client: new Client({ host: 'localhost', database: 'mydb', user: 'postgres', password: process.env.PGPASSWORD ?? '' }) }) }); const rows = await db.selectFrom('person').selectAll().execute(); console.log(rows);
Debug
Known issues
deprecatedThe library's own README advises against using it; recommends using Kysely's PostgresDialect with max: 1 instead.
fix
Use Kysely's PostgresDialect with pool max: 1, or consider Kysely's built-in single-connection support.
affects: *
gotchaNo onCreateConnection callback available; clients are created via Client constructor only.
fix
Configure client directly; for custom connection setup, use Kysely's PostgresDialect with a custom pool.
affects: >=0.1.0
gotchaSingle connection means no concurrent query support; queries are queued sequentially.
fix
Ensure your application does not require concurrent database connections.
affects: *
gotchaIn serverless environments, lazy connection construction may be beneficial; this dialect creates the client immediately.
fix
Consider using Kysely's PostgresDialect with a pool to allow lazy connection creation.
affects: *
breakingVersion 0.1.0 initial release; no known breaking changes yet.
fix
Update to latest version.
affects: <0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'kysely-pg-client' or its corresponding type declarations.
Package not installed or missing peer dependencies.
fix
npm install kysely-pg-client pg kysely
TypeError: client.connect is not a function
Provided object is not a valid pg.Client instance.
fix
Ensure you import Client from 'pg' and call new Client({...}).
Error: The 'PostgresClientDialect' instance has not been initialized.
Client connection failed, likely due to wrong connection parameters.
fix
Check database host, port, user, password, and database name.
Upgrade
Version history
0.1.14latest on npm
Audit
Dependencies
pgrequiredRequired as peer dependency; provides the `Client` class used by the dialect.
kyselyrequiredRequired as peer dependency; the dialect is designed for use with Kysely.
Agent activity
11 hits · last 30 days
node
10
Resources
kysely-pg-client — npm install kysely-pg-client · libregistry