Skip to content

What is IndexedDB

Key idea:

IndexedDB — a browser-built-in NoSQL database storing structured data (records, blobs, files) on the client. Async API, transactional, supports indexes, 100+ MB storage. Used in PWAs for offline-first + large-volume cache. Replaces deprecated WebSQL. Alternatives: localForage (wrapper), Dexie.js (ORM-like).

Below: details, example, related terms, FAQ.

Details

  • Object stores (= collections): organize records by keyPath
  • Transactions: readonly / readwrite / versionchange
  • Indexes: secondary keys for efficient queries
  • Storage quota: ~20-60% of free disk (Chrome), ~1GB (Safari)
  • Eviction: browser may clear when space is low

Example

const request = indexedDB.open('myDB', 1);
request.onupgradeneeded = e => {
  e.target.result.createObjectStore('users', { keyPath: 'id' });
};
request.onsuccess = e => {
  const tx = e.target.result.transaction('users', 'readwrite');
  tx.objectStore('users').put({ id: 1, name: 'Alice' });
};

Related Terms

Learn more

Frequently Asked Questions

IndexedDB vs localStorage?

localStorage — 5-10 MB, sync, string-only. IndexedDB — gigabytes, async, structured objects + indexes.

Mobile support?

Yes, every modern browser (Safari iOS, Chrome Android). Safari is partially limited in PWA context.

Eviction — will my data disappear?

When disk space is tight — yes. For critical data use <code>navigator.storage.persist()</code>.