IndexedDBAdapter
Persistent storage for browsers
IndexedDBAdapter uses the browser's IndexedDB API. Data persists across sessions.
How it works
- Each collection is an object store with
idas keyPath - Auto-increment is handled by IndexedDB
- Indexes are created during migration (
onupgradeneeded) - A
_ctrodb_metastore holds schema version and metadata
Schema migration
When you change the schema version, IndexedDB fires onupgradeneeded.
The adapter creates new object stores and indexes:
const db = new Database({
schema: {
version: 2, // bump to trigger migration
collections: {
todos: {
fields: { title: { type: "string" } },
indexes: [{ field: "title" }],
},
},
},
})
New collections and indexes are added. Existing data is preserved.
Browser support
All modern browsers (Chrome, Firefox, Safari, Edge) support IndexedDB.
The adapter checks for window.indexedDB at runtime.
Transaction behavior
Uses IDBTransaction with readwrite mode across all object stores.
If the callback throws, tx.abort() is called.
Limitations
- Not available in Node.js
- IndexedDB size limits vary by browser (typically 50MB–unlimited)
- Blocked on database version change (tab conflict)
How is this guide?
Last updated on Jun 20, 2026