Powerful asynchronous state management, server-state utilities and data fetching. Fetch, cache, update, and wrangle all forms of async data in your TS/JS, React, Vue, Solid, Svelte & Angular applications all without touching any "global state"
Read the Docsimport { useQuery } from '@tanstack/react-query'
function Todos() {
const { data, isPending, error } = useQuery({
queryKey: ['todos'],
queryFn: () => fetch('/api/todos').then(r => r.json()),
})
if (isPending) return <span>Loading...</span>
if (error) return <span>Oops!</span>
return <ul>{data.map(t => <li key={t.id}>{t.title}</li>)}</ul>
}
export default Todosimport { useQuery } from '@tanstack/react-query'
function Todos() {
const { data, isPending, error } = useQuery({
queryKey: ['todos'],
queryFn: () => fetch('/api/todos').then(r => r.json()),
})
if (isPending) return <span>Loading...</span>
if (error) return <span>Oops!</span>
return <ul>{data.map(t => <li key={t.id}>{t.title}</li>)}</ul>
}
export default TodosSee what teams are saying
"Honestly, if React Query had been around before Redux, I don't think Redux would have been nearly as popular as it was."
"If I could go back in time and mass myself... I would hand myself a flash drive with a copy of react-query on it."
"React Query won. There's no denying that."
"TanStack Query has been a game-changer for us. We love using it for react-admin."
"The more I use React + Vite + TanStack Router + TypeScript + TanStack Query, the more I love it."
"Combined with React Query, this stack has been a game-changer for my productivity."
"Honestly, if React Query had been around before Redux, I don't think Redux would have been nearly as popular as it was."
"If I could go back in time and mass myself... I would hand myself a flash drive with a copy of react-query on it."
"React Query won. There's no denying that."
"TanStack Query has been a game-changer for us. We love using it for react-admin."
"The more I use React + Vite + TanStack Router + TypeScript + TanStack Query, the more I love it."
"Combined with React Query, this stack has been a game-changer for my productivity."
With zero dependencies, TanStack Query is extremely lean given the dense feature set it provides. From weekend hobbies all the way to enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), TanStack Query is the battle-hardened tool to help you succeed at the speed of your creativity.
Instead of writing reducers, caching logic, timers, retry logic, complex async/await scripting (I could keep going...), you literally write a tiny fraction of the code you normally would. You will be surprised at how little code you're writing or how much code you're deleting when you use TanStack Query. Try it out with one of the examples below!
