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

@tanstack/query-core

Package Overview
Dependencies
Maintainers
2
Versions
284
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/query-core

The framework agnostic core that powers TanStack Query

  • 4.29.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.2M
increased by10.14%
Maintainers
2
Weekly downloads
 
Created

What is @tanstack/query-core?

The @tanstack/query-core package is a lightweight and powerful data synchronization library for JavaScript. It enables efficient server state management by providing hooks and utilities to fetch, cache, and update data in React applications. The core package is framework-agnostic and can be used with any JavaScript framework or UI layer.

What are @tanstack/query-core's main functionalities?

Data Fetching

This feature allows you to fetch data from an API or any asynchronous source. The useQuery hook returns the data, error, and loading state, making it easy to build UI components that react to data fetching state.

import { QueryClient, QueryCache, useQuery } from '@tanstack/query-core';

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

const { data, error, isLoading } = useQuery(['todos'], fetchTodos);

Data Caching

Data caching enables efficient data retrieval by storing fetched data in a cache. This reduces the need for unnecessary network requests, as subsequent requests for the same data can be served from the cache.

import { QueryClient, QueryCache } from '@tanstack/query-core';

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

queryClient.setQueryData(['todos'], updatedTodos);

Data Mutation

Data mutation is the process of updating data on the server and then synchronizing the updated data with the client. The useMutation hook is used to perform mutations, and it provides callbacks such as onSuccess to handle side effects like invalidating the cache to refetch updated data.

import { QueryClient, QueryCache, useMutation } from '@tanstack/query-core';

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

const mutation = useMutation(addTodo, {
  onSuccess: () => {
    queryClient.invalidateQueries(['todos']);
  },
});

Other packages similar to @tanstack/query-core

FAQs

Package last updated on 24 Apr 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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc