What is IndexedDB?
Answer
IndexedDB is a low-level, browser-based NoSQL database for storing significant amounts of structured data (including files/blobs) on the client side. Unlike localStorage (string key-value, ~5-10MB), IndexedDB can store gigabytes, complex objects, and supports indexes for efficient queries. It is asynchronous (non-blocking) and uses transactions for data integrity. Operations return IDBRequest objects — listen to onsuccess/onerror. Basic flow: open DB (indexedDB.open("name", version)), handle onupgradeneeded (schema setup), then create transactions to read/write. The API is callback-heavy and verbose — use wrapper libraries: Dexie.js (most popular, clean Promise-based API), localForage (falls back to localStorage), or the modern IDB library. Use cases: offline-first web apps (Progressive Web Apps), caching large datasets, client-side search, and storing user-generated content. Service Workers + IndexedDB = powerful offline capabilities.
Previous
What is Web Workers in JavaScript?
Next
What is the difference between CommonJS and ES Modules?