Skip to main content
@brushy/storage is isomorphic: one API for Node.js, browsers, React Native, and SSR.

Runtime matrix

SSR with React

@brushy/storage-react uses getServerSnapshot to return the initialValue on the server, avoiding hydration mismatches:
Create the storage instance once per app (singleton id) and pass it to StorageProvider.

Instance registry

  • createStorage({ id }) returns a shared instance per process for the same id
  • getStorageInstance(id) retrieves without creating
  • close() removes from registry; next createStorage creates fresh

Node.js timers

The expiry checkperiod interval calls unref() when available so background scans do not block process exit.

Cloning

useClones: true uses structuredClone when available. In older environments it falls back to JSON round-trip (functions and undefined in objects are lost).

DI integration

Register storage as a singleton in your DI container:
See Examples for Vite, Expo, Express, and Fastify layouts.