ConfigsApr 28, 2026·3 min read

Dexie.js — Minimalist IndexedDB Wrapper for the Web

A lightweight wrapper around IndexedDB that provides a clean Promise-based API for client-side storage in web applications.

Introduction

Dexie.js is a thin, Promise-based wrapper around the browser IndexedDB API. It smooths over the awkward event-driven IndexedDB interface and provides a query syntax that feels closer to a traditional database. Dexie adds less than 25 KB gzipped to your bundle while making client-side storage reliable and pleasant to use.

What Dexie.js Does

  • Wraps IndexedDB with a clean, chainable Promise-based query API
  • Defines schemas declaratively with auto-incrementing keys and compound indexes
  • Supports transactions with automatic retry on abort
  • Provides live query hooks for reactive UI frameworks like React and Svelte
  • Works in all modern browsers and in web workers

Architecture Overview

Dexie opens an IndexedDB database under the hood and translates its fluent API calls into IndexedDB transactions and cursor operations. Schema versioning is handled by mapping Dexie version declarations to IndexedDB upgrade events. The library adds a WhereClause abstraction that compiles predicates into efficient index scans rather than full table scans.

Self-Hosting & Configuration

  • Install from npm or load via a CDN script tag
  • No backend server is needed — all data lives in the browser
  • Define table schemas as strings with index hints (e.g., '++id, name, [first+last]')
  • Use Dexie Cloud (optional SaaS) for cross-device sync and access control
  • TypeScript definitions are included for full type safety

Key Features

  • Under 25 KB gzipped with zero runtime dependencies
  • Compound, multi-entry, and unique indexes for flexible querying
  • Bulk operations (bulkAdd, bulkPut, bulkDelete) for batch writes
  • Observable queries via dexie-react-hooks or useLiveQuery
  • Schema versioning with automatic upgrade migrations

Comparison with Similar Tools

  • Raw IndexedDB — verbose event-driven API; Dexie provides Promises and a fluent query builder
  • localForage — simple key-value abstraction; Dexie supports indexes and structured queries
  • RxDB — full reactive database with replication; Dexie is lighter when you only need local storage
  • sql.js — SQLite compiled to WASM; Dexie uses the native IndexedDB engine and is smaller

FAQ

Q: Does Dexie.js work in Node.js? A: Not natively, since IndexedDB is a browser API. For testing, use fake-indexeddb as a polyfill.

Q: How much data can I store? A: Browser limits vary. Chrome and Firefox typically allow hundreds of megabytes per origin. Dexie itself imposes no additional limit.

Q: Can Dexie sync data to a server? A: The core library is local-only. Dexie Cloud is an optional service that adds real-time sync and authentication.

Q: Does Dexie support full-text search? A: Not built-in. You can implement a simple inverted index manually or combine Dexie with a search library like Lunr.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets