idb-keyval

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
47 /100 Fair
Development Activity 28
Maintenance 8
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
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

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
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 5 days ago
TypeScript
45%
AGPL 3.0

BrowserOS

AI Assistants · Browser

13,763

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
68
Dependency
Built with
TypeScript 45%
Rust 23%
Python 18%
Updated 4 days ago
Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,441

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
59
Repo Health
90
Technical
61
Dependency
Built with
Java 34%
TypeScript 27%
Scala 26%
Updated 1 months ago
Rust
65%
Other

GitButler

AI Development · Developer Tools · Devops

21,726

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
66
Dependency
Built with
Rust 65%
TypeScript 22%
Svelte 10%
Updated 4 days ago
TypeScript
99%
MIT

GraphQL Hive

Developer Tools · Devops · Monitoring

484

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
69
Dependency
Built with
TypeScript 99%
Updated 4 days ago
Scala
63%
AGPL 3.0

lila (Lichess)

Community

18,776

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
76
Dependency
Built with
Scala 63%
TypeScript 26%
Updated 4 days ago
TypeScript
93%
MIT

OpenReel Video

Video Editors

5,211

A browser-based, GPU-accelerated video editor with multi-track timelines, color grading, and 4K export — no uploads, no installs, no watermarks.

View details
66
Repo Health
80
Technical
74
Dependency
Built with
TypeScript 93%
Updated 1 months ago
TypeScript
94%
Apache 2.0

Openship

Devops · Hosting Control Panel

12,979

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
84
Repo Health
85
Technical
65
Dependency
Built with
TypeScript 94%
Updated 5 days ago
TypeScript
97%
MIT

Promptfoo

AI Development

25,506

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
TypeScript 97%
Updated 4 days 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