gitmyhub

Dexie.js

TypeScript ★ 14k updated 3d ago

A Minimalistic Wrapper for IndexedDB

A JavaScript library that wraps the browser's built-in IndexedDB storage in a clean, readable API, letting apps store and query data locally so they work offline, used in 100,000+ sites.

TypeScriptJavaScriptIndexedDBsetup: easycomplexity 2/5

Dexie.js is a JavaScript library that makes it much easier to store data inside a web browser. Browsers have a built-in storage system called IndexedDB, but it is notoriously awkward to use directly. Dexie wraps it in a cleaner, friendlier interface so developers can read and write data with short, readable code instead of layers of low-level event callbacks.

The library is used across roughly 100,000 websites, desktop apps built with Electron, and mobile apps built with Capacitor. It works in every major browser and patches over known bugs in IndexedDB implementations, which means apps behave more consistently for end users. Because the data lives in the browser itself, apps built with Dexie can continue working even when the user is offline.

The core API lets you define a database with named tables, then query those tables using methods like filtering by a field, sorting, limiting results, and doing bulk inserts or deletes in a single operation. Those bulk operations are fast because they take advantage of a lesser-known IndexedDB feature that skips waiting for a confirmation event on every write.

For teams that need data to sync across a user's devices or be shared with other users, the project offers a separate add-on called Dexie Cloud. That add-on adds real-time sync, built-in user authentication, and per-record access control without requiring the developer to build or run a backend server. The developer keeps writing the same Dexie code on the frontend, and Dexie Cloud handles synchronization either through a hosted service or a self-hosted setup.

There are also hooks and middleware systems for extending Dexie's behavior, and a companion package called dexie-react-hooks that lets React components automatically re-render when the database changes. The project has tutorials for React, Svelte, Vue, Angular, and plain JavaScript. Two older add-ons, dexie-observable and dexie-syncable, are no longer maintained and should be avoided in new projects.

Where it fits