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

@tanstack/react-query

Package Overview
Dependencies
Maintainers
2
Versions
345
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/react-query

Hooks for managing, caching and syncing asynchronous and remote data in React

  • 5.51.23
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.5M
increased by1.97%
Maintainers
2
Weekly downloads
 
Created

What is @tanstack/react-query?

The @tanstack/react-query package is a powerful tool for fetching, caching, and updating asynchronous data in React applications. It provides a set of hooks that enable developers to easily manage and synchronize server state with the UI, improving user experience and application performance.

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

Data Fetching

This feature allows you to fetch data asynchronously using the useQuery hook. You can specify a unique key for the query and a function that returns a promise. The hook returns the status of the query (loading, error, success) and the fetched data.

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

Mutation

Mutations are used to create, update, or delete data. The useMutation hook returns a mutate function that you can call with the new data. You can specify side effects to run on success, error, or mutation completion, such as invalidating queries to refetch data.

const mutation = useMutation(newTodo => axios.post('/todos', newTodo), { onSuccess: () => queryClient.invalidateQueries('todos') })

Automatic Refetching

React Query can automatically refetch data under certain conditions, such as when the window regains focus. This ensures that the user always sees the most up-to-date information without having to manually refresh the data.

const { data } = useQuery('todos', fetchTodos, { refetchOnWindowFocus: true })

Other packages similar to @tanstack/react-query

FAQs

Package last updated on 08 Aug 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