{"id":44274,"library":"apollo-cache-persist-dev","title":"Apollo Cache Persist Dev","description":"apollo-cache-persist-dev (v0.2.1) is a development preview of apollo-cache-persist, providing simple persistence for Apollo Client 2.0+ cache implementations including InMemoryCache and Hermes. It supports web (localStorage) and React Native (AsyncStorage) with automatic restore on app start and persistence on cache writes. Key features include configurable triggers (write, background), debounce, max size limits, and serialization. This dev package includes experimental changes and community PRs not yet merged into the stable release, with potential breaking changes. Alternative to manual cache serialization.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/apollographql/apollo-cache-persist","tags":["javascript","typescript"],"install":[{"cmd":"npm install apollo-cache-persist-dev","lang":"bash","label":"npm"},{"cmd":"yarn add apollo-cache-persist-dev","lang":"bash","label":"yarn"},{"cmd":"pnpm add apollo-cache-persist-dev","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for React Native storage, but the package itself is a peer dependency.","package":"@react-native-community/async-storage","optional":true},{"reason":"Peer dependency for using with InMemoryCache (or Hermes).","package":"apollo-cache-inmemory","optional":true}],"imports":[{"note":"PersistCache is a named export, not a default export.","wrong":"import persistCache from 'apollo-cache-persist-dev'","symbol":"persistCache","correct":"import { persistCache } from 'apollo-cache-persist-dev'"},{"note":"CachePersistor may not be available in the stable apollo-cache-persist package. Check imports carefully.","wrong":"import { CachePersistor } from 'apollo-cache-persist'","symbol":"CachePersistor","correct":"import { CachePersistor } from 'apollo-cache-persist-dev'"},{"note":"CommonJS require with destructuring for named export.","wrong":"const persistCache = require('apollo-cache-persist-dev')","symbol":"persistCache (CommonJS)","correct":"const { persistCache } = require('apollo-cache-persist-dev')"}],"quickstart":{"code":"import { InMemoryCache } from 'apollo-cache-inmemory';\nimport { persistCache } from 'apollo-cache-persist-dev';\n\nconst cache = new InMemoryCache();\n\nawait persistCache({\n  cache,\n  storage: window.localStorage,\n  key: 'my-cache-key',\n  debug: true,\n});\n\nconst client = new ApolloClient({\n  cache,\n  uri: 'https://api.example.com/graphql',\n});","lang":"typescript","description":"Shows how to persist an InMemoryCache to localStorage using persistCache with key and debug options."},"warnings":[{"fix":"Use the correct package name in package.json and imports.","message":"Package name change from 'apollo-cache-persist' to 'apollo-cache-persist-dev' might cause confusion if you accidentally use the stable package.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Use @react-native-async-storage/async-storage for React Native.","message":"AsyncStorage from @react-native-community/async-storage is deprecated in favor of @react-native-async-storage/async-storage.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Always await persistCache() before new ApolloClient(...).","message":"PersistCache() must be awaited before creating ApolloClient, otherwise queries might execute before cache is restored.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'write' trigger on web, or provide a custom trigger.","message":"The 'background' trigger only works on React Native, not web. If used on web, persistence will not occur.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set maxSize: false for unlimited or increase limit as needed.","message":"Max size defaults to 1 MB. If exceeded, cache is truncated and app starts cold. This may cause unexpected data loss.","severity":"breaking","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'2.0':26 'altern':85 'apollo':1,6,17,24 'apollo-cache-persist':16 'apollo-cache-persist-dev':5 'app':45 'asyncstorag':40 'automat':42 'background':58 'break':83 'cach':2,7,18,27,50,88 'chang':70,84 'client':25 'communiti':72 'configur':55 'debounc':59 'dev':4,9,66 'develop':13 'experiment':69 'featur':53 'herm':32 'implement':28 'includ':29,54,68 'inmemorycach':30 'javascript':90 'key':52 'limit':62 'localstorag':36 'manual':87 'max':60 'merg':76 'nativ':39 'packag':67 'persist':3,8,19,22,48 'potenti':82 'preview':14 'provid':20 'prs':73 'react':38 'releas':80 'restor':43 'serial':64,89 'simpl':21 'size':61 'stabl':79 'start':46 'support':34 'trigger':56 'typescript':91 'v0.2.1':10 'web':35 'write':51,57 'yet':75","created_at":"2026-06-07T12:49:20.068384+00:00","updated_at":"2026-06-07T12:49:20.068384+00:00","problems":[{"fix":"Change to: import { persistCache } from 'apollo-cache-persist-dev'","cause":"Importing as default export instead of named export.","error":"TypeError: persistCache is not a function"},{"fix":"npm install @react-native-community/async-storage or switch to @react-native-async-storage/async-storage.","cause":"Missing peer dependency for React Native storage.","error":"Cannot find module '@react-native-community/async-storage' or its corresponding type declarations."},{"fix":"Use: persistCache({...}) without new.","cause":"Using new on persistCache which is a function, not a class.","error":"PersistCache is not a constructor (e.g., new persistCache())"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/apollographql/apollo-cache-persist#readme","github":"https://github.com/apollographql/apollo-cache-persist","docs":null,"changelog":null,"pypi":null,"npm":"apollo-cache-persist-dev","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}