Hooks
Reusable React hooks for common patterns
A collection of type-safe, SSR-compatible React hooks organized by category.
Storage
Hooks for persisting data in browser storage:
| Hook | Description |
|---|---|
| useLocalStorageState | Sync state with localStorage (persistent) |
| useSessionStorageState | Sync state with sessionStorage (per-tab) |
| useIndexedDB | Store large data in IndexedDB |
Comparison
| Feature | useLocalStorageState | useSessionStorageState | useIndexedDB |
|---|---|---|---|
| Storage Limit | ~5MB per origin | ~5MB per origin | GBs (quota-based) |
| Data Types | JSON serializable | JSON serializable | Any (objects, blobs) |
| Persistence | Forever | Until tab closes | Forever |
| Cross-tab | Syncs | Isolated | Shared |
| API Style | Synchronous | Synchronous | Asynchronous |
| Best For | Preferences, tokens | Forms, wizards | Large data, offline |
Device
Hooks for accessing device capabilities and hardware:
| Hook | Description |
|---|---|
| useBattery | Access real-time battery information |
| useMediaDevices | List cameras, microphones, and speakers |
| useGeolocation | Get device location using GPS or Wi-Fi |
Utility
General-purpose utility hooks:
| Hook | Description |
|---|---|
| useIsMounted | Detect if component is mounted (SSR safe) |
| useClipboard | Copy and read text from the clipboard |
| useDebouncedState | Debounce state values |
| useDebouncedCallback | Debounce callback functions |
| useThrottledState | Throttle state values |
| useThrottledCallback | Throttle callback functions |