ultrastorage
Gives localStorage superpowers: rich values, expiration, namespaces, validation, and subscriptions.
ultrastorage keeps the familiar Storage API and adds the features applications need. Use it directly from JavaScript or TypeScript, or subscribe from React.
Install
npm install ultrastorage
Store your first value
import { createStorage } from 'ultrastorage';
const storage = createStorage({ prefix: 'app' });
storage.setItem('user', { name: 'Alice', age: 30 });
storage.getItem<{ name: string; age: number }>('user');
// { name: 'Alice', age: 30 }
What you can do
- Store rich values, including Maps, Sets, Dates, and circular references.
- Expire entries with a TTL or absolute timestamp.
- Namespace keys with prefixes and separators.
- Subscribe to changes within a page and across tabs.
- Validate reads using synchronous Standard Schema libraries.
- Choose a backend or serializer, including an in-memory backend.
- Use React hooks with typed defaults, functional updates, and SSR.
The package provides ESM, CJS, and TypeScript declarations. Get started or jump to the storage API.