Reference · print-friendly
One page for design reviews. Walk top to bottom; stop when a row rejects the current candidate.
| If… | Prefer… |
|---|---|
| Re-fetch is cheap; no offline need | Memory only (skip durable client store) |
| Tiny string flags | sessionStorage / localStorage (sparingly) |
| HTTP assets / app shell / resource responses | Cache Storage (+ usually a service worker) |
| Durable structured app data (drafts, entities) | IndexedDB |
| File-shaped private pipelines (media, exports, DB files) | OPFS |
| User must open/save real OS paths | File System Access pickers (user-visible FS) |
| Multi-device source of truth | Server + explicit sync — not OPFS alone |
await navigator.storage.getDirectory() (no picker)
exports/, media/,
generation prefixes)
getFileHandle / getDirectoryHandle with
optional { create: true }
handle.remove() or
parent.removeEntry(name); list via async iteration
createWritable → write →
close; read with getFile()
createSyncAccessHandle()
getSize, read,
write, truncate, flush,
close (buffers, not raw strings)
createWritable fails until close()
QuotaExceededError; bound growth
estimate() / optional persist(); clear-data
and Safari hostility still apply
“We use OPFS | IndexedDB | Cache | pickers | memory | server because job; tree is folder layout + handles; I/O is writable streams | worker sync access; we own one risk (quota / lock / re-hydrate / private-vs-UVFS).”