React hook-based caching library that combines IndexedDB persistence with React state synchronization, version 1.4.1. Provides a useCached hook to fetch, cache, and retrieve data asynchronously, automatically updating React components when data arrives. Uses idb-keyval for IndexedDB operations and supports custom drivers, optional context isolation via CacheProvider, and TypeScript with generic type parameters. Released on npm with moderate frequency.
npm install react-idb-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic setup with CacheProvider, useCached hook, loading data from API, and rendering cached value.
Wrap components with <CacheProvider> or call useCached({ context: false }) for local-only cacheUpdate expire callback signature: expire(key, value) instead of ({ data, meta }) => booleanUse `import NullDB from 'react-idb-cache/driver/NullDB'`
Specify generics as useCached<string, 'data', number>() for example
Change `import useCached from 'react-idb-cache'` to `import { useCached } from 'react-idb-cache'`Ensure import path is exactly 'react-idb-cache/driver/NullDB' (case-sensitive)
Update expire callback: expire(key, value) => boolean instead of old ({ data, meta }) => boolean