Registry / database / kysely-bun-sqlite

kysely-bun-sqlite

JSON →
library0.4.0jsnpmunverified

Kysely dialect for Bun's built-in SQLite module (bun:sqlite). Current version 0.4.0, requires Bun >=1.1.31 and Kysely ^0.28.2. Provides a thin integration layer leveraging Bun's native SQLite driver for zero-dependency SQLite access. Unlike better-sqlite3-based dialects, this avoids native addon compilation and uses Bun's built-in module. Includes TypeScript types. Released sparsely with minor updates.

npm install kysely-bun-sqlite
INSTALL
IMPORT
SIG · KYSELY-BUN-SQLITE
K
kysely-bun-sqlite
databasejavascriptv0.4.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.

BunSqliteDialect
import { BunSqliteDialect } from 'kysely-bun-sqlite'
const { BunSqliteDialect } = require('kysely-bun-sqlite')
ESM-only; import syntax required. Named export.
Kysely
import { Kysely } from 'kysely'
import { Kysely } from 'kysely-bun-sqlite'
Kysely is the core library; only the dialect is from this package.
Database type (DB)
import type { DB } from './path/to/types'
Type parameters are user-defined; no type exports from this package except types inferred.

Creates an in-memory SQLite database using Bun's built-in driver and Kysely with the kysely-bun-sqlite dialect, defines a table, inserts a row, and queries it.

import Database from 'bun:sqlite'; import { BunSqliteDialect } from 'kysely-bun-sqlite'; import { Kysely, sql } from 'kysely'; interface Database { person: { id: number; name: string; age: number; }; pet: { id: number; name: string; species: string; }; } const dialect = new BunSqliteDialect({ database: new Database(':memory:'), }); const db = new Kysely<Database>({ dialect }); await db.schema .createTable('person') .addColumn('id', 'integer', (cb) => cb.primaryKey().autoIncrement()) .addColumn('name', 'text') .addColumn('age', 'integer') .execute(); await db.insertInto('person').values({ name: 'Alice', age: 30 }).execute(); const persons = await db.selectFrom('person').selectAll().execute(); console.log(persons);
Debug
Known issues
breakingRequires Bun >=1.1.31
fix
Update Bun to latest version.
affects: <1.1.31
breakingRequires Kysely ^0.28.2
fix
Upgrade Kysely to 0.28.2 or later.
affects: <0.28.2
gotchaESM-only package; require() fails
fix
Use import syntax. In Bun, ESM is default.
affects: >=0.4.0
gotchaThe dialect expects a Database instance from bun:sqlite, not a better-sqlite3 database
fix
Pass `new Database(...)` from 'bun:sqlite', not from any other SQLite package.
affects: all
gotchaBunSqliteDialect constructor argument is an object with `database` property; passing raw database directly fails
fix
Use `new BunSqliteDialect({ database: yourDb })`.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'kysely-bun-sqlite'
Missing dependency or wrong package manager
fix
Run `bun add kysely-bun-sqlite` (not npm or yarn).
TypeError: BunSqliteDialect is not a constructor
Using CommonJS require() instead of ESM import
fix
Use `import { BunSqliteDialect } from 'kysely-bun-sqlite'`
Error: The "dialect" is not a Dialect object
Passing an instance of Database directly to Kysely instead of dialect object
fix
Create a `BunSqliteDialect` instance with a `database` property and pass it. See quickstart.
Error: Cannot find module 'kysely'
Missing peer dependency
fix
Install kysely: `bun add kysely`
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
kyselyrequiredPeer dependency; library is a Kysely dialect
Agent activity
2 hits · last 30 days
node
2
Resources
kysely-bun-sqlite — npm install kysely-bun-sqlite · libregistry