Registry / database / kysely-bun-sql

kysely-bun-sql

JSON →
library0.2.0jsnpmunverified

A Kysely dialect and driver for PostgreSQL that leverages Bun's native SQL capabilities. Current stable version is 0.2.0, released with monthly cadence. Provides a `BunSqlDialect` for Kysely to execute queries using `Bun.sql` instead of a traditional pg driver, offering better performance and concurrency via Bun's built-in connection pooling. Requires Bun >=1.3.0 and Kysely ^0.28.8. Key differentiator: eliminates need for separate pg client in Bun applications.

npm install kysely-bun-sql
INSTALL
IMPORT
SIG · KYSELY-BUN-SQL
K
kysely-bun-sql
databasejavascriptv0.2.0
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.

BunSqlDialect
import { BunSqlDialect } from 'kysely-bun-sql'
const BunSqlDialect = require('kysely-bun-sql')
ESM-only; cannot use CommonJS require.
Kysely
import { Kysely } from 'kysely'
Kysely comes from the kysely package, not kysely-bun-sql.
BunSqlConnector
import { BunSqlConnector } from 'kysely-bun-sql'
Available since v0.2.0 for advanced configurations.

Example connecting to PostgreSQL, querying a table, and closing the connection.

import { Kysely, sql } from 'kysely' import { BunSqlDialect } from 'kysely-bun-sql' interface Database { person: { id: number name: string age: number } } const db = new Kysely<Database>({ dialect: new BunSqlDialect({ url: process.env.DATABASE_URL ?? 'postgresql://user:pass@localhost/mydb' }) }) const persons = await db.selectFrom('person').selectAll().execute() console.log(persons) await db.destroy()
Debug
Known issues
breakingRequires Bun >=1.3.0; does not work with older versions or Node.js.
fix
Install Bun 1.3.0+.
affects: >=0.0.0
gotchaKysely version must be exactly ^0.28.8. Other versions may not be compatible.
fix
Use Kysely ^0.28.8.
affects: >=0.0.0
gotchaBunSqlDialect uses Bun's built-in pool. Node.js pg pool libraries are not supported.
fix
Use Bun runtime only; avoid mixing with pg driver.
affects: >=0.0.0
deprecatedThe 'BunSqlDialect' constructor accepts 'url' but also accepts 'connectionString' alias; 'url' preferred for consistency.
affects: >=0.2.0
Errors
Common errors & fixes
Error: The module "./dist/index.js" doesn't export a "BunSqlDialect" export
Importing from wrong package or wrong symbol name.
fix
Use: import { BunSqlDialect } from 'kysely-bun-sql' (note spelling: 'BunSqlDialect' not 'BunSQLDialect').
TypeError: Bun.sql is not a function
Using the library outside Bun runtime (e.g., Node.js).
fix
Run the script with `bun run`.
Cannot find module 'kysely-bun-sql'
Package not installed or missing dependency.
fix
Run: bun add kysely-bun-sql and also add peer dependency: bun add kysely@0.28.8
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
kyselyrequiredPeer dependency for Kysely query builder integration
bunoptionalRuntime required (native SQL driver); not an npm dependency
Agent activity
24 hits · last 30 days
node
24
Resources
kysely-bun-sql — npm install kysely-bun-sql · libregistry