@secundus-studio/stift-persisters
v0.4.32
Published
Offline pack storage for @secundus-studio/stift-core: OPFS, IndexedDB (idb-keyval), and Cache Storage PersisterAdapters, plus a best-effort fallback chain.
Maintainers
Readme
@secundus-studio/stift-persisters
Offline pack storage for @secundus-studio/stift-core: three PersisterAdapter
backends plus a best-effort chain. Any object implementing
PersisterAdapter (get/set/del/keys over raw pack bytes) works as a
custom backend — no registration needed.
Quickstart (recommended)
import { createStift } from '@secundus-studio/stift-core'
import { createBestEffortPersister } from '@secundus-studio/stift-persisters'
const Stift = createStift({
...runtime,
persister: await createBestEffortPersister(),
})Tries OPFS → IndexedDB → Cache Storage → in-memory, returning the first the
environment supports. Never throws for a missing backend. Pass
onBackend to observe which one won.
Pinned backends
import { createOpfsPersister } from '@secundus-studio/stift-persisters/opfs'
import { createIdbKeyvalPersister } from '@secundus-studio/stift-persisters/idb-keyval'
import { createCacheApiPersister } from '@secundus-studio/stift-persisters/cache-api'- OPFS — separate filesystem budget; needs a secure context. Takes the
root handle (
await navigator.storage.getDirectory()). - IndexedDB (via
idb-keyval) — near-universal. Optional customdbName/storeName. - Cache Storage — shares the origin's HTTP-cache quota; inspectable in
DevTools. Optional
cacheName/scope/storage(inject a fake in tests).
Each subpath bundles independently — an OPFS-only app never downloads
idb-keyval.
