IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high-performance searches of this data. While Web Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data. IndexedDB provides a solution. This is the main landing page for MDN's IndexedDB coverage — here we provide links to the full API reference and usage guides, browser support details, and some explanation of key concepts.
Note: This feature is available in Web Workers
Note: IndexedDB API is powerful, but may seem too complicated for simple cases. If you'd prefer a simple API, try libraries in See also section that make IndexedDB more programmer-friendly.
- Read more about IndexedDB key characteristics and basic terminology.
- Learn to use IndexedDB asynchronously from first principles with our Using IndexedDB guide.
- Combine IndexedDB for storing data offline with Service Workers for storing assets offline, as outlined in Making PWAs work offline with Service workers.
Note: Like most web storage solutions, IndexedDB follows a same-origin policy. So while you can access stored data within a domain, you cannot access data across different domains.
Operations performed using IndexedDB are done asynchronously, so as not to block applications.
There are a number of web technologies that store data of one kind or another on the client side (i.e. on your local disk). IndexedDB is most commonly talked about. The process by which the browser works out how much space to allocate to web data storage and what to delete when that limit is reached is not simple, and differs between browsers. Browser storage limits and eviction criteria attempts to explain how this works, at least in the case of Firefox.
Provides access to a database. This is the interface implemented by the global object
indexedDBand is therefore the entry point for the API.
Represents a request to open a database.
Represents a connection to a database. It's the only way to get a transaction on the database.
Represents a transaction. You create a transaction on a database, specify the scope (such as which object stores you want to access), and determine the kind of access (read only or readwrite) that you want.
Generic interface that handles database requests and provides access to results.
Represents an object store that allows access to a set of data in an IndexedDB database, looked up via primary key.
Also allows access to a subset of data in an IndexedDB database, but uses an index to retrieve the record(s) rather than the primary key. This is sometimes faster than using
Iterates over object stores and indexes.
Iterates over object stores and indexes and returns the cursor's current value.
Defines a key range that can be used to retrieve data from a database in a certain range.
Defines a key range that can be used to retrieve data from a database in a certain range, sorted according to the rules of the locale specified for a certain index (see the
IDBObjectStore.createIndex().) This interface isn't part of the 2.0 specification.
|Indexed Database API 3.0 |
- localForage: A Polyfill providing a simple name:value syntax for client-side data storage, which uses IndexedDB in the background, but falls back to Web SQL (deprecated) and then localStorage in browsers that don't support IndexedDB.
- Dexie.js: A wrapper for IndexedDB that allows much faster code development via nice, simple syntax.
- JsStore: An IndexedDB wrapper with SQL like syntax.
- MiniMongo: A client-side in-memory mongodb backed by localstorage with server sync over http. MiniMongo is used by MeteorJS.
- PouchDB: A client-side implementation of CouchDB in the browser using IndexedDB
- idb: A tiny (~1.15k) library that mostly mirrors the IndexedDB API, but with small improvements that make a big difference to usability.
- idb-keyval: A super-simple-small (~600B) promise-based keyval store implemented with IndexedDB
- $mol_db: Tiny (~1.3kB) TypeScript facade with promise-based API and automatic migrations.
- RxDB A NoSQL client side database that can be used on top of IndexedDB. Supports indexes, compression and replication. Also adds cross tab functionality and observability to IndexedDB.