Skip to main content

Moving from idb-keyval

idb-keyval is a fraction of Strata Storage's size (the figures are below). If IndexedDB key-value is all you need, keep it. Move when expiry, encryption or cross-tab sync would otherwise be code you write around it, or when the same values have to reach a native store.

The calls​

idb-keyvalStrata Storage
set(key, value)storage.set(key, value, { storage: 'indexedDB' })
get(key)storage.get(key, { storage: 'indexedDB' })
del(key)storage.remove(key, { storage: 'indexedDB' })
keys()storage.keys(undefined, { storage: 'indexedDB' })
clear()storage.clear({ storage: 'indexedDB' })
createStore(db, store)defineStorage({ adapters: { indexedDB: { dbName } } })

defaultStorages: ['indexedDB'] saves you repeating the storage option on each call. setMany, getMany and update have no direct equivalent: loop over set() and get().

Carry existing entries over​

idb-keyval accepts any valid IndexedDB key: numbers, dates and arrays as well as strings. Strata keys are strings, so decide what the others become. This keeps strings and turns numbers into strings.

import { entries } from 'idb-keyval';
import { defineStorage } from 'strata-storage';

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

export async function moveFromIdbKeyval(): Promise<void> {
if (await storage.get<boolean>('moved:idb-keyval')) return;
for (const [key, value] of await entries()) {
if (typeof key === 'string' || typeof key === 'number') {
await storage.set(String(key), value);
}
}
await storage.set('moved:idb-keyval', true);
}

What you take on​

You're trading 805 bytes for a larger package; the table below has both measurements. Features such as TTL and encryption are off until you ask for them, so a plain set() behaves as it did.

Delete the old database with idb-keyval's clear() in a later release, after you've read real keys back.

idb-keyval 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-keyval yourself, or see the side-by-side page.

Store or capabilityidb-keyvalStrata 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 factidb-keyvalStrata Storage
LicenceApache-2.0 (source)MIT (source)
npm version6.3.03.1.4
Bundle size805 bytes gzipped, 2,132 minified, version 6.3.0, 7 Nov 2026 (source)21,468 bytes gzipped, 79,645 minified, version 3.1.4, 7 Nov 2026 (source)
Weekly downloads15,406,746, 31 Oct 2026 to 6 Nov 2026 (source)486, 31 Oct 2026 to 6 Nov 2026 (source)