idb-keyval

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
41 /100 Fair
Development Activity 12
Maintenance 0
Community 52
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 78
Code Quality 82
Innovation 88
Learning Curve 90

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 14 apps in this directory

TypeScript
96%
Other

Refly

AI Development · Automation · No Code Platforms

7,537

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

View details
68
Repo Health
76
Technical
63
Dependency
Built with
TypeScript 96%
Updated 1 weeks ago
Python
57%
Other

Sentry

Analytics · Developer Tools · Monitoring

45,632

Developer-first error tracking and performance monitoring platform with AI-powered root-cause analysis across 20+ languages and frameworks.

View details
95
Repo Health
80
Technical
66
Dependency
Built with
Python 57%
TypeScript 42%
Updated 6 days ago
TypeScript
48%
MIT

supermemory

AI Development · AI Memory · Note Taking

31,370

The state-of-the-art memory and context engine for AI agents — ranked #1 on all three major AI memory benchmarks.

View details
88
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 48%
MDX 32%
Python 17%
Updated 6 days ago
TypeScript
85%
Apache 2.0

superset

AI Code Assistants · AI Development

15,503

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 85%
Updated 6 days ago
TypeScript
84%
Other

twenty

CRM

59,615

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 84%
MDX 14%
Updated 1 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