createStorage() keeps data in memory only.
Built-in adapters
local / session resolve to null and behave as memory-only.
Custom SyncPersist
Implement the synchronous storage interface for React Native, Electron, or encrypted backends:
Factory helpers
Envelope format
Persisted values are wrapped in a versioned envelope:@brushy/localstorage on-disk format is not read automatically. See Migration.
Compression
Enable at instance level:set(key, value, { compress: true }).
Write-through behavior
set/ttlwrite to memory first, then persistgethydrates memory from persist on missdel/flushAll/ expiry remove from both layers- Persist failures call
onErrorand may causesetto returnfalse
Quota errors
DOMException with name QuotaExceededError is mapped to StorageError with code QuotaExceeded. Handle via onError or try/catch around set.