Socket
Socket
Sign inDemoInstall

@tanstack/query-sync-storage-persister

Package Overview
Dependencies
1
Maintainers
2
Versions
238
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/query-sync-storage-persister

A persister for synchronous storages, to be used with TanStack/Query


Version published
Weekly downloads
187K
increased by9.95%
Maintainers
2
Created
Weekly downloads
 

Package description

What is @tanstack/query-sync-storage-persister?

@tanstack/query-sync-storage-persister is a package designed to persist TanStack Query cache data to various storage solutions, such as localStorage or sessionStorage. This allows for the state of queries to be saved and restored, providing a more seamless user experience across sessions.

What are @tanstack/query-sync-storage-persister's main functionalities?

Persisting Query Cache to Local Storage

This feature allows you to persist the query cache to the local storage. The code sample demonstrates how to set up the persister with localStorage and integrate it with the TanStack Query client.

const { persistQueryClient } = require('@tanstack/query-sync-storage-persister');
const { QueryClient, QueryCache } = require('@tanstack/react-query');
const { createSyncStoragePersister } = require('@tanstack/query-sync-storage-persister');

const queryClient = new QueryClient({
  queryCache: new QueryCache(),
});

const localStoragePersister = createSyncStoragePersister({
  storage: window.localStorage,
});

persistQueryClient({
  queryClient,
  persister: localStoragePersister,
});

Persisting Query Cache to Session Storage

This feature allows you to persist the query cache to the session storage. The code sample demonstrates how to set up the persister with sessionStorage and integrate it with the TanStack Query client.

const { persistQueryClient } = require('@tanstack/query-sync-storage-persister');
const { QueryClient, QueryCache } = require('@tanstack/react-query');
const { createSyncStoragePersister } = require('@tanstack/query-sync-storage-persister');

const queryClient = new QueryClient({
  queryCache: new QueryCache(),
});

const sessionStoragePersister = createSyncStoragePersister({
  storage: window.sessionStorage,
});

persistQueryClient({
  queryClient,
  persister: sessionStoragePersister,
});

Other packages similar to @tanstack/query-sync-storage-persister

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