Skip to content
DEV VAULT
Frameworks
Tools
Packages
Backend Concepts
DevOps
Platforms
Effects
Guide
Frameworks
Tools
Packages
Backend Concepts
DevOps
Platforms
Effects
Guide
Home
/
Packages
/
@tanstack/react-query
/
Edit
Packages
Edit entry
@tanstack/react-query
Core details
Title
*
Description
*
@tanstack/react-query (formerly React Query) is a data synchronization library for React, handling fetching, caching, mutations, and optimistic updates server-state. It reduces boilerplate for API interactions.
Category
*
Frameworks
Tools
Packages
Backend Concepts
DevOps
Platforms
Effects
Usage & Trade-offs
All fields support markdown. Use concise bullets and concrete situations.
When to use it
*
Use React Query when: - Managing server data in React apps. - Needing background refetching. - Implementing infinite queries. - Avoiding Redux for async state.
Pros
*
- Automatic caching and stale-while-revalidate. - Devtools for inspection. - Infinite scroll support. - Mutations with rollbacks. - Type-safe with TS.
Cons
*
- Learning query keys and invalidation. - Over-fetching if not tuned. - Bundle size for small apps. - React-only. - Pairs with auth libs.
Notes
Note: Use useQuery for reads. Invalidate on focus for freshness. Paginate with query params.
Cancel
Save Changes