Registry / database / cojson-storage-sqlite

cojson-storage-sqlite

JSON →
library0.20.18jsnpmunverified

SQLite persistence layer for CoJSON/Jazz (jazz.tools) collaborative state management. Current stable version: 0.20.18. Released weekly alongside the Jazz monorepo. Purpose-built for local-first apps where SQLite (via better-sqlite3 or bun:sqlite) is the backing store — no network dependency. Unlike generic key-value stores, it preserves CoJSON's CRDT merge semantics and sync topology. TypeScript-native ESM package with full type declarations.

npm install cojson-storage-sqlite
INSTALL
IMPORT
SIG · COJSON-STORAGE-SQL
C
cojson-storage-sqlite
databasejavascriptv0.20.18
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.

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}).
fix
Pass 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().
fix
Use 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.
fix
Use 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.
fix
Use 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.
fix
Install 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.
fix
Switch 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.
fix
Use new SQLiteStorage({ dbPath: '...' }) then await storage.initialize(). Do not call create().
Error: Cannot find module 'better-sqlite3'.
better-sqlite3 is not installed.
fix
Run: npm install better-sqlite3
Upgrade
Version history
0.20.18latest on npm
Audit
Dependencies
cojson-storagerequiredProvides the storage backend interface that this SQLite adapter implements.
cojsonrequiredCore CoJSON data model and sync primitives.
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
cojson-storage-sqlite — npm install cojson-storage-sqlite · libregistry