Does react-query ever persist cached values on the client?
I've been doing some work with Next 13's app directory, RSC, etc. I've been making my way through figuring out exactly how Next caches things, and I've been integrating this all with react-query, among other things.
I've been seeing some counterintuitive things, which I'm working through, but I just wanted to confirm, with certainty, that react-query will always have an empty cache when you cmd+r and refresh your browser. I can't imagine react-query is storing anything in localStorage, indexedDb, etc. I checked those things, and they're empty, but I figured I'd ask, to be certain.
2 Replies
conscious-sapphire•3y ago
yes, that's right. The react-query cache is in memory only. You can use the
PersistQueryClientProvider to opt into persistence to an external storage, like localstorage or indexDB. But that's a separate package to install, so if you didn't opt-in to that, everything will be empty on a hard page reload.adverse-sapphireOP•3y ago
Thanks!