{"id":44595,"library":"cojson-storage-sqlite","title":"CoJSON Storage SQLite","description":"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.","status":"active","version":"0.20.18","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install cojson-storage-sqlite","lang":"bash","label":"npm"},{"cmd":"yarn add cojson-storage-sqlite","lang":"bash","label":"yarn"},{"cmd":"pnpm add cojson-storage-sqlite","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the storage backend interface that this SQLite adapter implements.","package":"cojson-storage","optional":false},{"reason":"Core CoJSON data model and sync primitives.","package":"cojson","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require throws ERR_REQUIRE_ESM.","wrong":"const SQLiteStorage = require('cojson-storage-sqlite')","symbol":"SQLiteStorage","correct":"import { SQLiteStorage } from 'cojson-storage-sqlite'"},{"note":"The adapter factory is exported from this package, not from 'cojson-storage'.","wrong":"import { createSQLiteStorageAdapter } from 'cojson-storage'","symbol":"createSQLiteStorageAdapter","correct":"import { createSQLiteStorageAdapter } from 'cojson-storage-sqlite'"},{"note":"Default export is the same as named export in this package.","wrong":"import { default as SQLiteStorage } from 'cojson-storage-sqlite'","symbol":"SQLiteStorage (default import)","correct":"import SQLiteStorage from 'cojson-storage-sqlite'"}],"quickstart":{"code":"import { SQLiteStorage } from 'cojson-storage-sqlite';\n\nconst storage = new SQLiteStorage({\n  dbPath: './data/jazz.db'\n});\n\nawait storage.initialize();\n\n// Now use storage with CoJSON/Jazz\n// e.g., const account = await Account.create({ storage });","lang":"typescript","description":"Creates a SQLite-backed storage instance for CoJSON/Jazz, initializing the database file."},"warnings":[{"fix":"Pass dbPath instead of a pre-opened database handle.","message":"v0.18 changed the constructor signature from (options: {db: Database}) to (options: {dbPath: string}).","severity":"breaking","affected_versions":">=0.18.0"},{"fix":"Use new SQLiteStorage({ dbPath: '...' }) and await storage.initialize().","message":"v0.20 removed the async create() factory method; use new SQLiteStorage constructor and initialize().","severity":"breaking","affected_versions":">=0.20.0"},{"fix":"Use the 'dbPath' string option instead.","message":"Using the 'db' option (passing a Database object) is deprecated since v0.18 and removed in v0.20.","severity":"deprecated","affected_versions":">=0.18.0 <0.20.0"},{"fix":"Use dynamic import() or set {\\\"type\\\": \\\"module\\\"} in package.json.","message":"This package is ESM-only; attempting require() will fail with ERR_REQUIRE_ESM.","severity":"gotcha","affected_versions":">=0.15.0"},{"fix":"Install better-sqlite3: npm install better-sqlite3","message":"SQLiteStorage depends on better-sqlite3 (Node) or bun:sqlite (Bun) being available at runtime. No automatic installation — you must install better-sqlite3 yourself.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.20.18':16 'alongsid':19 'app':30 'back':42 'better':35 'better-sqlite3':34 'built':25 'bun':38 'cojson':1,55 'cojson/jazz':8 'collabor':10 'crdt':57 'current':13 'declar':71 'depend':46 'esm':66 'first':29 'full':69 'generic':48 'javascript':72 'jazz':21 'jazz.tools':9 'key':50 'key-valu':49 'layer':6 'local':28 'local-first':27 'manag':12 'merg':58 'monorepo':22 'nativ':65 'network':45 'packag':67 'persist':5 'preserv':54 'purpos':24 'purpose-built':23 'releas':17 'semant':59 'sqlite':3,4,32,39 'sqlite3':36 'stabl':14 'state':11 'storag':2 'store':43,52 'sync':61 'topolog':62 'type':70 'typescript':64,73 'typescript-n':63 'unlik':47 'valu':51 'version':15 'via':33 'week':18","created_at":"2026-06-07T12:50:54.415033+00:00","updated_at":"2026-06-07T12:50:54.415033+00:00","problems":[{"fix":"Switch to dynamic import(): const { SQLiteStorage } = await import('cojson-storage-sqlite'); or configure your project as ES module.","cause":"Using CommonJS require() on an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported."},{"fix":"Use new SQLiteStorage({ dbPath: '...' }) then await storage.initialize(). Do not call create().","cause":"Calling SQLiteStorage() without new or calling a removed create() factory.","error":"TypeError: Class constructor SQLiteStorage cannot be invoked without 'new'."},{"fix":"Run: npm install better-sqlite3","cause":"better-sqlite3 is not installed.","error":"Error: Cannot find module 'better-sqlite3'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"cojson-storage-sqlite","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}