IndexedDB: A NoSQL Database in Your Browser

Think of IndexedDB as a NoSQL database in the browser, built for large structured data that localStorage can't handle. It's ideal for offline apps or caching large assets. The footgun: browsers can evict your data, so it's not permanent storage.
Why it exists
Web Storage (localStorage/sessionStorage) is great for small, simple key-value pairs. But modern web apps often need to store large amounts of structured data on the client for offline functionality or caching complex objects. IndexedDB was created to provide a robust, high-performance database directly in the browser to solve this problem.
The mental model
IndexedDB is a transactional, object-oriented database that lives on the user's machine. Instead of thinking in SQL tables and rows, think of it as a JavaScript-based NoSQL database. You store entire JavaScript objects in "object stores" (like collections or tables) and can retrieve them efficiently using "indexes" on object properties.
How it works
All operations are asynchronous to prevent blocking the user interface. The process involves three main steps. First, you request to open a database with a specific version number; if the database is new or the version is higher, you define the schema by creating object stores and indexes. Second, once connected, you start a transaction on one or more object stores. Third, within that transaction, you can add, read, update, or delete objects. All communication happens via events fired on request objects, not promises or callbacks directly.
When to use it
Use IndexedDB for building offline-first applications where users can view and edit data without a network connection. It's also ideal for caching large, structured data from APIs to reduce network requests and improve performance, or for temporarily storing user-generated content (like a complex form or document) before it's sent to a server.
When not to use it
Avoid IndexedDB for small, simple data like user settings or authentication tokens; localStorage is simpler and sufficient for that. Because the API is low-level and event-based, it can be complex to use directly for simple needs. Never use it as a sole source of truth for critical data, as browsers can and will delete data under storage pressure.
One canonical example
A web-based email client could use IndexedDB to store a user's recent emails. It would create an "emails" object store and an index on the 'date' property. When the user goes offline, they can still read and search their inbox. The app queries IndexedDB to display the cached emails. When the connection is restored, it syncs any changes with the server.
Interview question
Which scenario best highlights a key advantage of IndexedDB over localStorage for client-side data storage?
- a.Storing small, frequently accessed user preferences.
- b.Managing large collections of structured data for offline access.Correct
- c.Ensuring critical application data is never evicted by the browser.
- d.Performing synchronous database operations to avoid UI blocking.
Why? this is the answer
The card states IndexedDB is designed for "large amounts of structured data" and "offline functionality," which is its primary advantage over localStorage. IndexedDB operations are asynchronous, and its data can be evicted by the browser under storage pressure.
Just read this? Test yourself on what you have been reading.
Read the original → developer.mozilla.org
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on web apis — each one lists the topics its interview covers.
See open roles