Socket
Socket
Sign inDemoInstall

@tanstack/react-query-persist-client

Package Overview
Dependencies
1
Maintainers
2
Versions
294
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/react-query-persist-client

React bindings to work with persisters in TanStack/react-query


Version published
Weekly downloads
241K
increased by9.09%
Maintainers
2
Install size
2.34 MB
Created
Weekly downloads
 

Package description

What is @tanstack/react-query-persist-client?

@tanstack/react-query-persist-client is a package that provides utilities to persist and rehydrate the state of React Query across sessions. This can be useful for maintaining the state of your queries even after a page reload or when navigating away from the application.

What are @tanstack/react-query-persist-client's main functionalities?

Persisting Query State

This feature allows you to persist the state of your queries using local storage. The `persistQueryClient` function is used to set up the persistence, and `createWebStoragePersistor` is used to specify the storage mechanism.

import { persistQueryClient } from '@tanstack/react-query-persist-client';
import { createWebStoragePersistor } from '@tanstack/react-query-persist-client/web-storage';

const queryClient = new QueryClient();
const persistor = createWebStoragePersistor({ storage: window.localStorage });
persistQueryClient({ queryClient, persistor });

Rehydrating Query State

This feature allows you to rehydrate the state of your queries from the persisted storage. The `persistQueryClientRestore` function is used to restore the state, ensuring that your queries are in the same state as they were before the page reload or navigation.

import { persistQueryClientRestore } from '@tanstack/react-query-persist-client';
import { createWebStoragePersistor } from '@tanstack/react-query-persist-client/web-storage';

const queryClient = new QueryClient();
const persistor = createWebStoragePersistor({ storage: window.localStorage });

persistQueryClientRestore({ queryClient, persistor });

Other packages similar to @tanstack/react-query-persist-client

FAQs

Last updated on 07 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc