Skip to main content

Moving from idb

idb is IndexedDB with promises: object stores, indexes, cursors and transactions stay in your hands. Strata hides all of those, so if you use them on purpose, this is the wrong move. It fits when you only ever call get and put, and you don't want to think in IndexedDB terms or you need the value elsewhere too.

The calls​

idbStrata Storage
db.put('drafts', value, key)storage.set('drafts:' + key, value)
db.get('drafts', key)storage.get('drafts:' + key)
db.delete('drafts', key)storage.remove('drafts:' + key)
db.getAllKeys('drafts')storage.keys(/^drafts:/)
db.getFromIndex(...)storage.query({ field: value }), a scan with no index
db.transaction(...)No equivalent: each call stands alone
upgrade() in openDBNot needed: there's no schema to version

If two writes must succeed or fail together, keep idb for that data. The prefix on the key is there because Strata has one key space per adapter rather than named object stores; namespace is the other way to separate them.

Copy one object store​

import { openDB } from 'idb';
import { defineStorage } from 'strata-storage';

export const storage = defineStorage({ defaultStorages: ['indexedDB', 'memory'] });

export async function moveDrafts(): Promise<void> {
if (await storage.get<boolean>('moved:idb-drafts')) return;
const db = await openDB('app');
for (const key of await db.getAllKeys('drafts')) {
await storage.set(`drafts:${String(key)}`, await db.get('drafts', key));
}
db.close();
await storage.set('moved:idb-drafts', true);
}

Calling openDB with no version opens the database as it stands and runs no upgrade. Strata's own database has a different name, so yours is left alone until you call deleteDB from idb, in a later release, after real keys have read back correctly.

idb as we checked it​

Last checked 7 Nov 2026. "Not stated" means the pages we checked don't mention it, not that the library can't do it. Check idb yourself, or see the side-by-side page.

Store or capabilityidbStrata Storage
localStorageNot stated on the pages we checkedYes
IndexedDBYes (source, 7 Nov 2026)Yes
sessionStorageNot stated on the pages we checkedYes
CookiesNot stated on the pages we checkedYes
URL parameters as a storeNot stated on the pages we checkedYes
iOS KeychainNot stated on the pages we checkedYes
Android secure storage (Keystore-backed)Not stated on the pages we checkedYes
Native preferences (UserDefaults / SharedPreferences)Not stated on the pages we checkedYes
Web and native stores behind one APINot stated on the pages we checkedYes
No runtime dependenciesYes (source, 7 Nov 2026)Yes
Package factidbStrata Storage
LicenceISC (source)MIT (source)
npm version8.0.43.1.4
Bundle size1,493 bytes gzipped, 3,650 minified, version 8.0.4, 7 Nov 2026 (source)21,468 bytes gzipped, 79,645 minified, version 3.1.4, 7 Nov 2026 (source)
Weekly downloads36,224,449, 31 Oct 2026 to 6 Nov 2026 (source)486, 31 Oct 2026 to 6 Nov 2026 (source)