A small, durable key‑value store for JavaScript runtimes
loam is an embedded key-value store for Node, Deno and Bun. One file on disk, crash-safe writes, ordered keys and transactions, in 41 KB with no native dependencies.
npm install loam- Size
- 41 KB
- Dependencies
- 0
- Runtimes
- Node 20+, Deno, Bun
db.put(key, value)
- Write logevery writeappended and synced
- Memory table1,204 keyssorted, in RAM
- Level 048,600 keysrecent files
- Level 11.2M keysmerged, compacted
What you get in 41 KB
The parts of a database you need for local data, and none of the parts that need a server.
- 01
Crash-safe by default
Every write goes to an append-only log and is synced before the promise resolves. Pull the plug mid-write and the store opens cleanly with everything that was acknowledged.
- 02
Ordered keys and range scans
Keys are kept sorted, so prefixes and ranges are a single call. Good for time series, queues and anything you'd otherwise index by hand.
- 03
Transactions without a server
Read and write several keys atomically. Conflicting transactions retry automatically, and readers never block writers.
- 04
One file, easy to back up
The whole store is a single file plus a small log. Copy it while it's open with the built-in snapshot call.
- 05
Typed values
Store strings, numbers, binary data or anything JSON can hold. TypeScript types flow from the store's schema to every read.
- 06
No native code
Pure TypeScript on top of each runtime's file APIs, so it installs anywhere: CI runners, Alpine images, edge functions with a disk.
From install to a transaction in one file
The same code runs on Node, Deno and Bun. Types come along for free.
Full API reference1Open a store. It creates the file if it isn't there.
import { open } from "loam";
const db = await open("./data/app.loam");2Write and read. Keys sort by their parts, so related keys stay together.
const today = ["orders", "2026-11-24"];
await db.put([...today, 1042], { total: 64.5 });
const order = await db.get([...today, 1042]);3Scan a range and update several keys in one transaction.
for await (const { key, value } of db.range({ prefix: today })) {
console.log(key[2], value.total);
}
await db.transaction(async (tx) => {
const stock = await tx.get(["stock", "SKU-118"]);
await tx.put(["stock", "SKU-118"], stock - 1);
await tx.put([...today, 1043], { total: 18 });
});Output
1040 22.00 1041 9.75 1042 64.50
Built in the open by 73 people
Maintained by two people with help from everyone below. New contributors are welcome, and most first pull requests are reviewed within a few days.
- Ada OkaforMaintainer
- Lukas BrennerMaintainer
- Mei TanakaStorage engine
- Sam RiveraDeno support
- Joon ParkDocs
- Ines FariaBenchmarks
- Theo LindqvistBun support
- Nadia HaddadTransactions
- Ravi MenonTesting
- Clara NovakTypeScript types
- Owen AchebeWindows fixes
- Yusuf DemirCompaction
- and 61 more
Sponsors
Sponsorships pay for the maintainers' time and the test machines for every runtime.
- Infrastructure
- Northbeam HostingQuillstack
- Supporters
- Tidewater LabsBramble AnalyticsKitelineFerro & Finch
- Individuals
- 43 people sponsor loam every month