Installation
Install the package and open a database.
npm install @minnowdb/corePlain JavaScript, no post-install step and no binary to fetch. It is around 159 KB gzipped — roughly a third of SQLite's WebAssembly build, which also has to download and compile its module before it can answer anything.
The engine speaks SQL and needs nothing else. If you also want a typed query builder, add the optional client:
npm install @minnowdb/clientIt ships as its own package, built only from the primitives at @minnowdb/core/plan — the same
ones any other builder would use. Every Minnow package shares a major version and moves
independently inside it, so any 0.x client works with any 0.x engine and npm refuses a
mixed-major pair on its own. See Versioning.
Entry points
| Import | What it is |
|---|---|
@minnowdb/core | The engine: MinnowDatabase and everything for running SQL in the current thread. |
@minnowdb/core/storage | Block stores: IndexedDbBlockStore, MemoryBlockStore, and the BlockStore contract. |
@minnowdb/core/worker | A ready-made worker entry. Point a module worker at it. |
@minnowdb/core/client | MinnowDatabaseClient, the main-thread half of the worker pair. |
@minnowdb/core/plan | Plan-construction primitives, for building a typed layer over the engine. |
@minnowdb/core/testing | FaultInjectingBlockStore, for testing behaviour under storage failure. |
@minnowdb/core/block-format | The on-disk block encoding, for tools that read blocks directly. |
@minnowdb/client | Optional typed query builder: createMinnow, InferDatabase. |
Opening a database
A database is an engine plus a block store. The store decides where blocks live; everything else is identical whichever one you choose.
import { MinnowDatabase } from "@minnowdb/core";
import { IndexedDbBlockStore } from "@minnowdb/core/storage";
const store = await IndexedDbBlockStore.open({ name: "shop" });
const db = new MinnowDatabase(store);For tests and for data that should not outlive the page, swap in the in-memory store — it implements the same contract, so nothing else changes:
import { MemoryBlockStore } from "@minnowdb/core/storage";
const db = new MinnowDatabase(new MemoryBlockStore());See Storage for what each adapter costs and guarantees.
Where it runs
Anything with IndexedDB and CompressionStream: current Chrome, Firefox, Safari, and Edge, in a
window or a worker. There is no Node build — the engine targets browsers, and the tests run it in
real ones.
Most applications should run the engine in a worker. The API is identical on either side of the boundary, and query execution then never competes with rendering.