Registry /
storage / apollo3-cache-persist-compressed
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CompressedLocalForageWrapper
✓ import { CompressedLocalForageWrapper } from 'apollo3-cache-persist-compressed'
✗ const CompressedLocalForageWrapper = require('apollo3-cache-persist-compressed')
ESM only; CJS require will not work as package is type: module.
LocalForageWrapper
✓ import { LocalForageWrapper } from 'apollo3-cache-persist'
✗ import { LocalForageWrapper } from 'apollo3-cache-persist-compressed'
LocalForageWrapper is provided by apollo3-cache-persist, not this package.
default import
✓ import AnyName from 'apollo3-cache-persist-compressed'
✗ const AnyName = require('apollo3-cache-persist-compressed').default
Package exports only CompressedLocalForageWrapper; default import will give undefined.
Demonstrates setting up compressed cache persistence with Apollo Client, including localForage configuration and persistCache call.
import { InMemoryCache } from '@apollo/client/core';
import { persistCache } from 'apollo3-cache-persist';
import { CompressedLocalForageWrapper } from 'apollo3-cache-persist-compressed';
import localforage from 'localforage';
const cache = new InMemoryCache();
localforage.config({
driver: localforage.INDEXEDDB,
name: 'apollo-cache-v2',
});
await persistCache({
cache,
storage: new CompressedLocalForageWrapper(localforage),
serialize: true,
});
const client = new ApolloClient({ cache });
Debug
Known issues
breakingCompressed storage is not backward-compatible with string-based cache. Existing uncompressed cache will be overwritten.fixUse a new localForage name (e.g., 'apollo-cache-v2') to avoid migration issues.
affects: all
gotchaserialize option in persistCache must be true (default). If false, compression will fail silently.fixEnsure serialize: true in persistCache options.
affects: all
gotchaCompressedLocalForageWrapper does not support custom serializers; it expects string data from apollo3-cache-persist.fixDo not use a custom serialize function; keep the default stringifier.
affects: all
deprecatedPackage is relatively new; no deprecations yet.
Errors
Common errors & fixes
Cannot find module 'apollo3-cache-persist-compressed' or its corresponding type declarations.
Missing dependency or TypeScript not resolving types.
fixnpm install apollo3-cache-persist-compressed
CompressedLocalForageWrapper is not a constructor
Using default import instead of named import.
fiximport { CompressedLocalForageWrapper } from 'apollo3-cache-persist-compressed' localforage is not defined
localforage not installed or imported.
fixnpm install localforage ; import localforage from 'localforage'
Audit
Dependencies
apollo3-cache-persistrequiredpeer dependency; the base library providing persistCache and LocalForageWrapper
localforagerequiredrequired by CompressedLocalForageWrapper for storage