Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@tanstack/query-sync-storage-persister
Advanced tools
A persister for synchronous storages, to be used with TanStack/Query
@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.
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,
});
redux-persist is a library used to persist and rehydrate a Redux store. It provides similar functionality in terms of persisting state to storage solutions like localStorage or sessionStorage. However, it is designed specifically for Redux, whereas @tanstack/query-sync-storage-persister is designed for TanStack Query.
localforage is a library that provides a simple API for storing data in various storage solutions, including IndexedDB, WebSQL, and localStorage. While it is not specifically designed for persisting query caches, it can be used in conjunction with other libraries to achieve similar functionality.
idb-keyval is a small library for storing key-value pairs in IndexedDB. It is a lower-level solution compared to @tanstack/query-sync-storage-persister, which is specifically designed for persisting TanStack Query caches. idb-keyval can be used as a building block for more complex persistence solutions.
FAQs
A persister for synchronous storages, to be used with TanStack/Query
The npm package @tanstack/query-sync-storage-persister receives a total of 128,122 weekly downloads. As such, @tanstack/query-sync-storage-persister popularity was classified as popular.
We found that @tanstack/query-sync-storage-persister demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.