Skip to content

Indexeddb and only persisting some queries #8642

Closed Answered by NathanVG
NathanVG asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks @TkDodo for the quick replies. May be worth adding an example of this to the docs.

We ended up using dehydrateOptions, will provide all code here for future reference:

import React, { Suspense, useEffect, useState } from 'react';
import { QueryClient } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client';
import { createIDBPersister } from './utils';

declare global {
  interface Window {
    toggleDevtools: () => void;
  }
}

const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      staleTime: Infinity,
      gcTime: Infinity,
      r…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@TkDodo
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by NathanVG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants