IndexedDB — Complete Guide
IndexedDB — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of JavaScript Tutorial on Toolliyo Academy.
On this page
JavaScript Tutorial · Lesson 56 of 100
IndexedDB
Basics ✓ → Objects & data ✓ → Async & DOM ✓ → Advanced → Tools → Projects
Advanced · 4 — Production skills · ~10 min · JS HTML DOM & Web APIs
What is this?
IndexedDB is a browser database for larger structured data — offline catalogs, drafts, or cached API responses.
Why should you care?
localStorage is small and synchronous; IndexedDB handles bigger async storage.
See it live — copy this example
Paste into an HTML file or the browser console (F12). Use Run below when the live editor is available.
// Simplified — real apps use idb library or wrappers
const request = indexedDB.open("MyDB", 1);
request.onupgradeneeded = () => {
request.result.createObjectStore("notes", { keyPath: "id" });
};
request.onsuccess = () => console.log("DB ready");
Run Example »
Edit the code below and click Run to see the result in Toolliyo’s live editor.
What happened?
- open is async.
- onupgradeneeded creates stores.
- CRUD uses transactions — more verbose than localStorage.
Practice next
- Open database and create object store in onupgradeneeded.
- Log success in onsuccess.
- Compare quota in Application tab.
- Bump DB version to add a second object store for drafts.
- Sketch read/write transaction flow in comments.
Remember
Async key-value + indexes Good for offline data More setup than localStorage
ScriptVerse offline catalog
Retail PWA caches product catalog in IndexedDB for browsing without network.
Outcome: IndexedDB supports larger structured offline data than localStorage allows.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!