Simple persistence for all Apollo Client 3 cache implementations, including InMemoryCache and Hermes. Version 0.15.0 supports web and React Native with multiple storage providers (AsyncStorage, localStorage, etc.). It restores cache asynchronously and persists on every write with debounce. Key differentiators: works with any Apollo 3 cache, simple API, TypeScript types shipped.
npm install apollo3-cache-persistNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to persist an InMemoryCache to localStorage using apollo3-cache-persist. Must be awaited before creating ApolloClient.
Use persistCache({ cache, storage, ... }) instead of persistCache(cache, storage, ...)Use the new persistCache() signature; remove any persistor.destroy() calls.
Always await persistCache() before instantiating ApolloClient.
Use 'new AsyncStorageWrapper(AsyncStorage)' or 'new LocalStorageWrapper(window.localStorage)'
Wrap storage in proper wrapper: new AsyncStorageWrapper(AsyncStorage)
Run npm install apollo3-cache-persist @apollo/client
Use await persistCache({ cache, storage: ... });