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

@tanstack/query-core

Package Overview
Dependencies
Maintainers
0
Versions
285
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

  • 5.62.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
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 17 Dec 2024

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