Docs
CR-SQLite
JS & The Browser
NodeJS

NodeJS

Given cr-sqlite is a run time loadable extension you can use it in nodejs with any sqlite bindings that you desire such as better-sqlite3 (opens in a new tab) or sqlite3 (opens in a new tab).

Example

import type { Database } from "better-sqlite3";
import SQLiteDB from "better-sqlite3";
 
// the crsqlite package exports the path to the extension
import { extensionPath } from "@vlcn.io/crsqlite";
 
const db: Database = new SQLiteDB('path-to-your-db');
// suggested settings for best performance of sqlite
db.pragma("journal_mode = WAL");
db.pragma("synchronous = NORMAL");
// load that extension with the `better-sqlite3` bindings
db.loadExtension(extensionPath);

Usage

The API for interacting with the database will be the same as whatever sqlite bindings you chose. Creating conflict free tables and merging databases is done entirely over SQL. See the cr-sqlite docs.

Listening for changes & Networking

Listening to changes from the databases and creating a sync server are covered in: