idb-keyval

A tiny promise-based key-value store built on IndexedDB for the browser

Library
npm
v6.3.0
3,229stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
59/100Fair
Development Activity56
Maintenance28
Community52
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture78
Code Quality82
Innovation88
Learning Curve90

idb-keyval is a minimal, promise-based wrapper around the browser’s IndexedDB API that exposes a familiar key-value interface — get, set, del, keys, values, entries — instead of IndexedDB’s verbose event-driven API. It ships as an ultra-small, tree-shakeable ES module (as little as ~295 bytes brotli’d for get/set alone) with batched setMany/getMany/delMany helpers, an atomic update() helper for race-free read-modify-write cycles, and support for custom named stores when the shared default store isn’t enough.

Because it’s a thin layer over native IndexedDB rather than a full ORM, it inherits IndexedDB’s persistence, storage quotas, and structured-clone value support (objects, arrays, dates, blobs) without adding parsing or serialization overhead. It’s commonly reached for wherever localStorage’s synchronous, string-only API is too limiting — offline-first web apps, PWAs, and client-side caches that need to store structured data asynchronously.

What You Get

  • Promise-based get/set/del/update/clear API over IndexedDB
  • Batched setMany/getMany/delMany for faster, atomic bulk writes and reads
  • keys()/values()/entries() bulk readers with fast-path getAll()/getAllKeys() support
  • createStore() for named custom databases/stores beyond the default keyval-store
  • Sub-kilobyte, tree-shakeable ESM build plus legacy compat and UMD bundles

Common Use Cases

  • Offline-first web apps and PWAs caching structured data client-side
  • Replacing localStorage where synchronous, string-only storage is too limiting
  • Persisting large blobs, files, or images in the browser without a server round-trip
  • Client-side caching layers for API responses or computed state across sessions

Under The Hood

Architecture — The entire library lives in a single 277-line src/index.ts module. Each store is represented by a UseStore function type that takes a transaction mode (“readonly”/“readwrite”) and a callback receiving an IDBObjectStore; createStore() closes over a lazily-opened, cached IDBDatabase promise (getDB()) and re-opens it if Safari closes the connection unexpectedly. promisifyRequest() is the single bridge point that turns any IDBRequest or IDBTransaction’s success/complete and error/abort events into a resolved or rejected Promise, and every exported function (get, set, del, update, setMany, getMany, delMany, clear, keys, values, entries) is built on top of that one primitive plus the shared store callback pattern. Bulk readers (keys/values/entries) branch on a fast path using native getAll()/getAllKeys() when available and fall back to manual cursor iteration (eachCursor()) for older engines.

Tech Stack — Written in TypeScript and built with Rollup (rollup.config.js), using @rollup/plugin-typescript for compilation, @rollup/plugin-babel with an IE10 preset to produce compat/UMD legacy bundles, and @rollup/plugin-terser for minification; glob and del handle build housekeeping and a custom size-report script tracks brotli’d bundle size. The package.json exports map ships ESM, CJS, compat, and UMD outputs from one source tree. There are zero runtime dependencies, and .nvmrc/pnpm-lock.yaml pin the dev toolchain to Node 22.

Code Quality — test/index.ts is a 553-line Mocha + Chai suite that runs in a real browser (via test/index.html) against a live IndexedDB, covering get/set/del/clear/update/setMany/getMany/delMany/keys/values/entries plus isolation between custom stores, and it layers in compile-time type assertions using conditional-type-checks. Errors are not wrapped in custom classes — they propagate as the native IDBRequest.error via each function’s promise rejection, which is consistent but leaves error messages entirely up to the browser’s IndexedDB implementation. Naming is deliberately terse and consistent (get/set/del rather than delete, to dodge the reserved word), and every exported function carries a JSDoc block with parameter descriptions.

API Design — The public surface is about a dozen flat top-level functions sharing one optional trailing customStore parameter, so the common case (import { get, set } from ‘idb-keyval’) needs zero configuration, while advanced multi-store usage only requires calling createStore() once. Function names mirror Map/Storage conventions (get/set/del/keys/values/entries), which keeps the API instantly familiar, and the update() helper solves a real correctness pitfall (racy get-then-set) that the README calls out explicitly with a before/after example.

Used by 13 apps in this directory

TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
49%
AGPL 3.0

BrowserOS

Browser · AI Assistants

13,248

The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.

View details
87
Repo Health
82
Technical
69
Dependency
Built with
TypeScript49%
Rust22%
Python16%
Updated today
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,437

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

View details
70
Repo Health
90
Technical
62
Dependency
Built with
Java34%
TypeScript27%
Scala26%
Updated 1 weeks ago
Rust
69%
Other

GitButler

Developer Tools · Devops · AI Development

21,531

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Rust69%
TypeScript18%
Svelte12%
Updated today
TypeScript
98%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

485

Open-source GraphQL schema registry and observability platform with breaking change detection, federation support, and CI/CD integration for teams of any size.

View details
90
Repo Health
81
Technical
70
Dependency
Built with
TypeScript98%
Updated today
Scala
63%
AGPL 3.0

lila (Lichess)

Community

18,642

The forever-free, ad-free, open-source chess server powering millions of real-time games, AI analysis, puzzles, and tournaments worldwide.

View details
89
Repo Health
80
Technical
78
Dependency
Built with
Scala63%
TypeScript26%
Updated today
TypeScript
93%
Apache 2.0

Openship

Devops · Hosting Control Panel

11,078

Openship is an open-source, self-hostable deployment platform that points at a repo and builds, ships, routes, and TLS-terminates the app — driven from a desktop app, web dashboard, or CLI.

View details
82
Repo Health
85
Technical
65
Dependency
Built with
TypeScript93%
Updated today
TypeScript
97%
MIT

Promptfoo

AI Development

24,362

An open-source CLI and library for evaluating and red-teaming LLM applications — replace trial-and-error prompt engineering with systematic evals, vulnerability scanning, and CI/CD integration.

View details
90
Repo Health
73
Technical
68
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
96%
Other

Refly

No Code Platforms · AI Development · Automation

7,490

Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.

View details
66
Repo Health
76
Technical
64
Dependency
Built with
TypeScript96%
Updated 3 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search