TanStack Query
TanStack Query is a powerful async state management library that simplifies fetching, caching, synchronizing, and updating server state in your applications.Installation
Get started by installing TanStack Query in your project
Quick Start
Build your first query in minutes with a complete example
Essential Concepts
Learn the core concepts and patterns of TanStack Query
TypeScript
Full TypeScript support with type inference and safety
Why TanStack Query?
TanStack Query eliminates the complexity of managing server state in your application. It provides a simple, declarative API for data fetching while handling all the complex logic behind the scenes.Key Features
Smart Caching
Automatic caching with configurable stale times and garbage collection. Your data is cached intelligently to minimize network requests.
Background Updates
Automatic background refetching keeps your data fresh. Queries update on window focus, network reconnection, and configurable intervals.
Request Deduplication
Multiple components requesting the same data trigger only one network request. Results are shared automatically.
Optimistic Updates
Update your UI optimistically before server confirmation. Roll back automatically on error for a seamless user experience.
Infinite Scrolling
Built-in support for infinite queries and pagination. Load more data seamlessly as users scroll.
DevTools
Powerful devtools for inspecting queries, mutations, and cache state in real-time during development.
Framework Support
TanStack Query works seamlessly across multiple frameworks:- React Query - The most popular data-fetching library for React
- Vue Query - First-class support for Vue 3
- Svelte Query - Native integration with Svelte
- Solid Query - Built for SolidJS applications
- Angular Query - Experimental support for Angular
All framework adapters share the same core API, making it easy to transfer knowledge between projects.
Protocol Agnostic
TanStack Query doesn’t care how you fetch your data. Use it with:- REST APIs
- GraphQL
- gRPC
- WebSockets
- Any async function that returns a Promise
Production Ready
Trusted by thousands of applications in production:- Lightweight - Small bundle size with tree-shaking support
- Type-safe - Full TypeScript support with excellent type inference
- Battle-tested - Used by major companies and open source projects
- Well-documented - Comprehensive guides and API documentation
- Active development - Regular updates and improvements from the community
Get Started
Install TanStack Query
Add the package to your project using your preferred package manager.View installation guide →
Set up QueryClient
Configure the QueryClient and wrap your app with QueryClientProvider.See quick start →
Build your first query
Use the
useQuery hook to fetch and cache data with automatic background updates.Learn essential concepts →Community and Support
Join thousands of developers using TanStack Query:- GitHub Discussions - Ask questions and share ideas
- Discord - Chat with the community
- GitHub Issues - Report bugs and request features