Registry / database / kysely-sqlite

kysely-sqlite

JSON →
library0.2.0jsnpmunverified

A Kysely dialect for Node.js native sqlite module (`node:sqlite`) in Node 22+. Version 0.2.0 actively maintained with weekly releases. Key differentiator: uses Node's built-in SQLite binding (no native addon compilation, no better-sqlite3 dependency), making it lightweight and zero-config for Node 22+. Based on the official better-sqlite3 dialect codebase, ensuring similar API patterns.

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

SqliteDialect
import { SqliteDialect } from 'kysely-sqlite'
const { SqliteDialect } = require('kysely-sqlite')
This package is ESM-only via Node's native module system; require() will fail.
DatabaseSync
import { DatabaseSync } from 'node:sqlite'
import { DatabaseSync } from 'sqlite'
DatabaseSync is part of Node's built-in node:sqlite module, not an npm package.
Kysely
import { Kysely } from 'kysely'
import { Kysely } from 'kysely-sqlite'
Kysely is the core library; kysely-sqlite only provides the dialect.
SqliteDialect (type)
import type { SqliteDialect } from 'kysely-sqlite'
import { SqliteDialect } from 'kysely-sqlite'
For type-only imports, use `import type` to avoid runtime side-effects in TypeScript.

Create a Kysely instance with the native SQLite dialect, run a schema migration, insert a row, and query it back.

import { DatabaseSync } from 'node:sqlite'; import { Kysely } from 'kysely'; import { SqliteDialect } from 'kysely-sqlite'; const db = new Kysely({ dialect: new SqliteDialect({ database: new DatabaseSync('db.sqlite'), }), }); await db.schema.createTable('users') .addColumn('id', 'integer', (cb) => cb.primaryKey().autoIncrement()) .addColumn('name', 'text') .execute(); const user = await db.insertInto('users') .values({ name: 'Alice' }) .returningAll() .executeTakeFirstOrThrow(); console.log(user); await db.destroy();
Debug
Known issues
breakingNode.js version must be >=22 (using node:sqlite module)
fix
Ensure Node.js version is 22 or higher
affects: >=0.0.0
gotchaDatabaseSync is instantiated directly; do not reuse across Kysely instances
fix
Create a new DatabaseSync for each Kysely instance
affects: >=0.0.0
gotchaESM-only: require() will throw ERR_REQUIRE_ESM
fix
Use import or set type: module in package.json
affects: >=0.0.0
deprecatedkysely-sqlite is still early (v0.2.0); API may change without major version bump
fix
Pin to exact version and test upgrades
affects: <1.0.0
Errors
Common errors & fixes
TypeError: DatabaseSync is not a constructor
Importing DatabaseSync from wrong location (e.g., 'sqlite' instead of 'node:sqlite')
fix
Use: import { DatabaseSync } from 'node:sqlite'
ERR_REQUIRE_ESM
Using require() for ESM-only package
fix
Switch to import statement or set "type": "module" in package.json
TypeError: sqlite_database is not an object
Passing a string path instead of a DatabaseSync instance to the dialect constructor
fix
Instantiate DatabaseSync and pass it: new SqliteDialect({ database: new DatabaseSync('path') })
Error: Cannot find module 'node:sqlite'
Node.js version below 22
fix
Upgrade Node.js to >=22
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
kyselyrequiredPeer dependency; the core query builder and runtime
Agent activity
9 hits · last 30 days
node
8
Resources
kysely-sqlite — npm install kysely-sqlite · libregistry