Table of contents
IndexedDB is an API for client-side storage of significant amounts of structured data and for high performance searches on this data using indexes. While DOM Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data. IndexedDB provides a solution.
IndexedDB provides separate APIs for synchronous and asynchronous access. The synchronous API is intended to be used inside workers.
Asynchronous API
The asynchronous API methods return without blocking the calling thread. To get asynchronous access to a database, call open() on the indexedDB attribute of a window object. This method returns an IDBRequest object; asynchronous operations communicate to the calling application by firing events on IDBRequest objects.
IDBCursoriterates over object stores and indexes.IDBDatabaserepresents a connection to a database. It's the only way to get a transaction on the database.IDBFactoryprovides access to a database.IDBEnvironmentprovides access to a client-side database. It is implemented by window objects.IDBIndexprovides access to the metadata of an index.IDBObjectStorerepresents an object store.IDBOpenDBRequestrepresents a request to open a database.IDBRequestprovides access to results of asynchronous requests to databases and database objects. It is what you get when you call an asynchronous method.IDBTransactionrepresents 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 write) you want.IDBVersionChangeEventindicates that the version of the database has changed.
Early version of the specification also defined the now removed interface. They are still documented in case you need to update previously writtent code:
IDBVersionChangeRequestrepresents a request to change the version of a database. The way to change the version of the database has since changed (by callingIDBFactory.open()rather thanIDBDatabase.setVersion()) and the interfaceIDBOpenDBRequestnow have the functionality of the removedIDBVersionChangeRequest.
Synchronous API
To get synchronous access to a database, call open() on the
Unimplemented
indexedDBSync attribute of a worker object. This returns an IDBDatabaseSync object, which enables you to create, open, and remove object stores and indexes, set the version of the database, and create transactions.
IDBCursorSynciterates over object stores and indexes.IDBDatabaseSyncrepresents a connection to a database. It's the only way to get a transaction on the database.IDBEnvironmentSyncprovides access to a client-side database. It is implemented by worker objects.IDBFactorySyncprovides access to a database.IDBIndexSyncprovides access to the metadata of an index.IDBObjectStoreSyncrepresents an object store.IDBTransactionSynccreates a transaction in the database.
Shared interfaces
The following interfaces are used by both the synchronous and the asynchronous APIs.
IDBDatabaseExceptionrepresents exception conditions that can be encountered while performing database operations.IDBKeyRangedefines a range of keys.
Example
See live example.
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Asynchronous API | 12 webkit | 4.0 (2.0) | -- | -- | -- |
| Synchronous API (used with WebWorkers) | -- | -- See bug 553412 | -- | -- | -- |
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Asynchronous API | -- | 6.0 (6.0) | -- | -- | -- |
Storage limits
For Google Chrome, you can have up to 5 MB of storage, by default. Installed apps can have unlimited storage if you set your manifest file to have unlimited storage and your user grants that permission to your app.
See also
- Basic Concepts About IndexedDB
- Using IndexedDB
- A simple TODO list using HTML5 IndexedDB. Note that this tutorial is based on an old version of the specification and do not work on up-to-date browsers: e.g. it still uses the removed
setVersion()method. - Indexed Database API specification
- IndexedDB — The Store in Your Browser

