For AI agents: the complete documentation index is available at https://silt-db.dev/llms.txt, the full documentation bundle is available at https://silt-db.dev/llms-full.txt, and this page is available as Markdown at https://silt-db.dev/guide/quick-start.md.

Quick start

This example stores a note, queries it, changes it, and reopens the SQLite file to read the saved change. It uses the asynchronous API and Node's built-in SQLite driver.

Run the example

Use Node.js 24 or newer. Silt's package names currently refer to local npm workspaces; a public npm release is not yet available.

git clone https://github.com/startupjs/silt-db.git
cd silt-db
npm ci
node examples/docs-quick-start.mjs

Repository access is required while the repository is private. The example creates silt-guide.sqlite in your current directory and can be run again. You can choose a different file with node examples/docs-quick-start.mjs ./another-demo.sqlite.

The complete example

The runnable file contains the following code. Workspace imports resolve after npm ci when you run it inside the repository.

import { openDatabase } from '@silt-db/sqlite';

const filename = process.argv[2] ?? './silt-guide.sqlite';
let db = await openDatabase(filename);

try {
  const notes = db.collection('notes');

  // Replace this demo note, or insert it if it does not exist yet.
  await notes.replaceOne(
    { _id: 'welcome' },
    { _id: 'welcome', text: 'Build something local', archived: false },
    { upsert: true },
  );

  const activeNotes = await notes.find({ archived: false }).sort({ _id: 1 }).toArray();
  console.log('Active notes:', activeNotes);

  await notes.updateOne({ _id: 'welcome' }, { $set: { text: 'Saved in SQLite' } });

  await db.close();
  db = await openDatabase(filename);

  const saved = await db.collection('notes').findOne({ _id: 'welcome' });
  console.log('After reopening:', saved);
} finally {
  await db.close();
}

The final document has text: 'Saved in SQLite'. Closing the database releases the connection; reopening the same filename preserves its documents. The replaceOne(..., { upsert: true }) call makes this example repeatable by resetting its single demo note.

collection() returns a handle immediately. Writes, findOne(), cursor consumption, transactions, and close() return promises. Always await them.

Choose a driver

ImportIntended use
@silt-db/sqliteNode's built-in node:sqlite driver in Node; platform export conditions select Expo in supported browser and React Native bundlers.
@silt-db/sqlite/better-sqlite3Recommended Node server setup with the optional better-sqlite3 peer.
@silt-db/sqlite/expoExplicit Expo driver for web, iOS, and Android.
@silt-db/sqlite/portableAn existing application-provided SQLite driver.

The development workspace includes better-sqlite3, so you can try the server driver by changing the example's import:

import { openDatabase } from '@silt-db/sqlite/better-sqlite3';

When Silt opens a writable Node file itself, it enables WAL and synchronous=FULL by default. Both Node drivers execute SQLite synchronously on the calling thread; the shared promise API does not move queries into a worker thread. Long-running queries can therefore block other work on that thread.

An existing connection keeps its owner's configuration unless you explicitly request changes. See connections and options for ownership, WAL, read-only access, and custom drivers. Expo needs additional platform setup described in the Expo guide.

Next steps

Continue with queries and updates, then aggregations and joins. Read the compatibility contract before using Silt as a replacement for an existing MongoDB or Mingo workload.