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.
SQLiteStorage
✓ import { SQLiteStorage } from 'cojson-storage-sqlite'
✗ const SQLiteStorage = require('cojson-storage-sqlite')
ESM-only package; CommonJS require throws ERR_REQUIRE_ESM.
createSQLiteStorageAdapter
✓ import { createSQLiteStorageAdapter } from 'cojson-storage-sqlite'
✗ import { createSQLiteStorageAdapter } from 'cojson-storage'
The adapter factory is exported from this package, not from 'cojson-storage'.
SQLiteStorage (default import)
✓ import SQLiteStorage from 'cojson-storage-sqlite'
✗ import { default as SQLiteStorage } from 'cojson-storage-sqlite'
Default export is the same as named export in this package.
Creates a SQLite-backed storage instance for CoJSON/Jazz, initializing the database file.
import { SQLiteStorage } from 'cojson-storage-sqlite';
const storage = new SQLiteStorage({
dbPath: './data/jazz.db'
});
await storage.initialize();
// Now use storage with CoJSON/Jazz
// e.g., const account = await Account.create({ storage });
Debug
Known issues
breakingv0.18 changed the constructor signature from (options: {db: Database}) to (options: {dbPath: string}).fixPass dbPath instead of a pre-opened database handle.
affects: >=0.18.0
breakingv0.20 removed the async create() factory method; use new SQLiteStorage constructor and initialize().fixUse new SQLiteStorage({ dbPath: '...' }) and await storage.initialize(). affects: >=0.20.0
deprecatedUsing the 'db' option (passing a Database object) is deprecated since v0.18 and removed in v0.20.fixUse the 'dbPath' string option instead.
affects: >=0.18.0 <0.20.0
gotchaThis package is ESM-only; attempting require() will fail with ERR_REQUIRE_ESM.fixUse dynamic import() or set {\"type\": \"module\"} in package.json. affects: >=0.15.0
gotchaSQLiteStorage depends on better-sqlite3 (Node) or bun:sqlite (Bun) being available at runtime. No automatic installation — you must install better-sqlite3 yourself.fixInstall better-sqlite3: npm install better-sqlite3
affects: all
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported.
Using CommonJS require() on an ESM-only package.
fixSwitch to dynamic import(): const { SQLiteStorage } = await import('cojson-storage-sqlite'); or configure your project as ES module. TypeError: Class constructor SQLiteStorage cannot be invoked without 'new'.
Calling SQLiteStorage() without new or calling a removed create() factory.
fixUse new SQLiteStorage({ dbPath: '...' }) then await storage.initialize(). Do not call create(). Error: Cannot find module 'better-sqlite3'.
better-sqlite3 is not installed.
fixRun: npm install better-sqlite3
Audit
Dependencies
cojson-storagerequiredProvides the storage backend interface that this SQLite adapter implements.
cojsonrequiredCore CoJSON data model and sync primitives.