Registry / database / kysely-wasm

kysely-wasm

JSON →
library1.2.1jsnpmunverified

kysely-wasm provides multiple Kysely dialects for running SQLite in WebAssembly environments. Version 1.2.1 requires peer dependency kysely >=0.26. It offers six dialects: SqlJsDialect (for sql.js, easy but no bigint), OfficialWasmDialect (for official SQLite Wasm build, supports OPFS in WebWorker), NodeWasmDialect (for node-sqlite3-wasm, native filesystem, no recompile), CrsqliteDialect (for vlcn.io/wasm, CRDT with IndexedDB), EmptyDialect (SQL generation only), and deprecated WaSqliteDialect (replaced by worker dialect). No bundled Wasm; users install their own.

npm install kysely-wasm
INSTALL
IMPORT
SIG · KYSELY-WASM
K
kysely-wasm
databasejavascriptv1.2.1
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.

SqlJsDialect
import { SqlJsDialect } from 'kysely-wasm'
const { SqlJsDialect } = require('kysely-wasm')
ESM-only; CommonJS require not supported.
OfficialWasmDialect
import { OfficialWasmDialect } from 'kysely-wasm'
import OfficialWasmDialect from 'kysely-wasm'
Named export, not default. Use import { OfficialWasmDialect }.
NodeWasmDialect
import { NodeWasmDialect } from 'kysely-wasm'
import { NodeWasmDialect } from 'kysely-wasm/dist/dialect'
All dialects are exported from the package root; do not import from subpaths.

Shows how to set up SqlJsDialect with sql.js and Kysely, execute a query, and clean up.

import { SqlJsDialect } from 'kysely-wasm' import { Kysely, sql } from 'kysely' import initSqlJs from 'sql.js' async function main() { const SQL = await initSqlJs() const db = new Kysely<{}>({ dialect: new SqlJsDialect({ database: new SQL.Database(), }), }) await sql`SELECT 1 AS result`.execute(db) db.destroy() } main()
Debug
Known issues
deprecatedWaSqliteDialect is deprecated and will be removed in future versions. Use the separate worker dialect package instead.
fix
Replace WaSqliteDialect with the worker dialect from https://github.com/subframe7536/kysely-sqlite-tools/tree/master/dialect-wasqlite-worker
affects: >=1.0.0
gotchaSqlJsDialect does not support BigInt; values exceeding Number.MAX_SAFE_INTEGER may lose precision.
fix
Use OfficialWasmDialect or NodeWasmDialect if BigInt support is required.
affects: >=1.0.0
gotchaOfficialWasmDialect with OPFS storage requires server to send COOP and COEP headers, and only works in WebWorkers.
fix
Ensure your server sets Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp, and use the dialect inside a WebWorker.
affects: >=1.0.0
gotchaNo Wasm files are bundled; you must install and provide your own SQLite Wasm file or package.
fix
Install the appropriate Wasm package (e.g., sql.js, @sqlite.org/sqlite-wasm) and pass it when creating the dialect.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'kysely-wasm'
The package is not installed or the import path is wrong.
fix
Install with: pnpm add kysely-wasm (or npm/yarn). Ensure import is correct: import { SqlJsDialect } from 'kysely-wasm'.
TypeError: SQL.Database is not a constructor
For SqlJsDialect, the 'database' option expects an instance of SQL.Database from sql.js.
fix
Ensure you have initialized sql.js correctly: const SQL = await initSqlJs(); const database = new SQL.Database();
TypeError: dialect is not a Kysely dialect
The dialect object is not correctly constructed; likely imported wrongly.
fix
Import the dialect class: import { SqlJsDialect } from 'kysely-wasm' and instantiate with new SqlJsDialect({...}).
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
kyselyrequiredpeer dependency, provides the query builder and core library
Agent activity
6 hits · last 30 days
node
6
Resources
kysely-wasm — npm install kysely-wasm · libregistry