Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tanstack/query-sync-storage-persister

Package Overview
Dependencies
Maintainers
1
Versions
271
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/query-sync-storage-persister

TODO

  • 4.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
195K
decreased by-3.72%
Maintainers
1
Weekly downloads
 
Created

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

Package last updated on 19 Jul 2022

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc