DeAI Research
Source · w3c

Indexed Database API 3.0

2026

cid bf87a1e87cb2b3d1223cc0b69e1f1f6fe3363295d8770297d2e8f394a9f27ad0 · original · open access · via w3c

Title: Indexed Database API 3.0
Authors: 
Venue: w3c
Year: 2026
Canonical: w3c:IndexedDB
URL: https://www.w3.org/TR/IndexedDB/
Collector: w3c
OA: true

ABSTRACT
Indexed Database API 3.0 Indexed Database API 3.0 W3C Working Draft, 30 October 2026 More details about this document This version: https://www.w3.org/TR/2026/WD-IndexedDB-3-20261030/ Latest published version: https://www.w3.org/TR/IndexedDB/ Editor's Draft: https://w3c.github.io/IndexedDB/ Previous Versions: https://www.w3.org/TR/2025/WD-IndexedDB-3-20250813/ https://www.w3.org/TR/2026/WD-IndexedDB-3-20261029/ History: https://www.w3.org/standards/history/IndexedDB-3/ Test Suite: https://github.com/web-platform-tests/wpt/tree/master/IndexedDB Feedback: GitHub Editor: Steve Becker (Microsoft) Former Editors: Ali Alabbas (Formerly of Microsoft) Joshua Bell (Formerly of Google) Copyright © 2026 World Wide Web Consortium. W3C® liability, trademark and permissive document license rules apply. Abstract This document defines APIs for a database of records holding simple values and hierarchical objects. Each record consists of a key and some value. Moreover, the database maintains indexes over records it stores. An application developer directly uses an API to locate records either by their key or by using an index. A query language can be layered on this API. An indexed database can be implemented using a persistent B-tree data structure. Status of this document This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C standards and drafts index. This document was published by the Web Applications Working Group as a Working Draft using the Recommendation track. Publication as a Working Draft does not imply endorsement by W3C and its Members. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than a work in progress. This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy. This document is governed by the 18 August 2025 W3C Process Document. This is the Third Edition of Indexed Database API. The First Edition, simply titled "Indexed Database API", became a W3C Recommendation on 8 January 2015. The Second Edition, titled "Indexed Database API 2.0", became a W3C Recommendation on 30 January 2018. Indexed Database API 3.0 is intended to supersede Indexed Database API 2.0. 1. Introduction User agents need to store large numbers of objects locally in order to satisfy off-line data requirements of Web applications. [WEBSTORAGE] is useful for storing pairs of keys and their corresponding values. However, it does not provide in-order retrieval of keys, efficient searching over values, or storage of duplicate values for a key. This specification provides a concrete API to perform advanced key-value data management that is at the heart of most sophisticated query processors. It does so by using transactional databases to store keys and their corresponding values (one or more per key), and providing a means of traversing keys in a deterministic order. This is often implemented through the use of persistent B-tree data structures that are considered efficient for insertion and deletion as well as in-order traversal of very large numbers of data records. The following example uses the API to access a "library" database. It has a "books" object store that holds books records stored by their "isbn" property as the primary key. Book records have a "title" property. This example artificially requires that book titles are unique. The code enforces this by creating an index named "by_title" with the unique option set. This index is used to look up books by title, and will prevent adding books with non-unique titles. Book records also have an "author" property, which is not required to be unique. The code creates another index named "by_author" to allow look-ups by this property. The code first opens a connection to the database. The upgradeneeded event handler code creates the object store and indexes, if needed. The success event handler code saves the opened connection for use in later examples. const request = indexedDB.open("library"); let db; request.onupgradeneeded = function() { // The database did not previously exist, so create object stores and indexes. const db = request.result; const store = db.createObjectStore("books", {keyPath: "isbn"}); const titleIndex = store.createIndex("by_title", "title", {unique: true}); const authorIndex = store.createIndex("by_author", "author"); // Populate with initial data. store.put({title: "Quarry Memories", author: "Fred", isbn: 123456}); store.put({title: "Water Buffaloes", author: "Fred", isbn: 234567}); store.put({title: "Bedrock Nights", author: "Barney", isbn: 345678}); }; request.onsuccess = function() { db = request.result; }; The following example populates the database using a transaction. const tx = db.transaction("books", "readwrite"); const store = tx.objectStore("books"); store.put({title: "Quarry Memories", author: "Fred", isbn: 123456}); store.put({title: "Water Buffaloes", author: "Fred", isbn: 234567}); store.put({title: "Bedrock Nights", author: "Barney", isbn: 345678}); tx.oncomplete = function() { // All requests have succeeded and the transaction has committed. }; The following example looks up a single book in the database by title using an index. const tx = db.transaction("books", "readonly"); const store = tx.objectStore("books"); const index = store.index("by_title"); const request = index.get("Bedrock Nights"); request.onsuccess = function() { const matching = request.result; if (matching !== undefined) { // A match was found. report(matching.isbn, matching.title, matching.author); } else { // No match was found. report(null); } }; The following example looks up all books in the database by author using an index and a cursor. const tx = db.transaction("books", "readonly"); const store = tx.objectStore("books"); const index = store.index("by_author"); const request = index.openCursor(IDBKeyRange.only("Fred")); request.onsuccess = function() { const cursor = request.result; if (cursor) { // Called for each matching record. report(cursor.value.isbn, cursor.value.title, cursor.value.author); cursor.continue(); } else { // No more matching records. report(null); } }; The following example shows one way to handle errors when a request fails. const tx = db.transaction("books", "readwrite"); const store = tx.objectStore("books"); const request = store.put({title: "Water Buffaloes", author: "Slate", isbn: 987654}); request.onerror = function(event) { // The uniqueness constraint of the "by_title" index failed. report(request.error); // Could call event.preventDefault() to prevent the transaction from aborting. }; tx.onabort = function() { // Otherwise the transaction will automatically abort due the failed request. report(tx.error); }; The database connection can be closed when it is no longer needed. db.close(); In the future, the database might have grown to contain other object stores and indexes. The following example shows one way to handle migrating from an older version. const request = indexedDB.open("library", 3); // Request version 3. let db; request.onupgradeneeded = function(event) { const db = request.result; if (event.oldVersion