All Technologies
Frameworks·expert

TanStack Query

Async state management for React

TanStack Query (formerly React Query) handles server state cleanly. Caching, background refetch, optimistic updates, and request deduplication - without me writing it from scratch.

4+years in production
40+projects shipped
expertproficiency

My take

Why I use TanStack Query

Most React state isn't UI state - it's a stale cache of server state. React Query treats it that way and saves me from rebuilding the same fetch-cache-invalidate logic in every project.

Want the broader stack philosophy? Read about how Sri picks tools or browse engineering insights.

Honest assessment

Strengths & tradeoffs

No tool is perfect. Here's what shines and what to watch for.

Strengths

  • Automatic caching, deduping, and background refetch
  • Excellent devtools
  • Optimistic updates with rollback
  • Pagination and infinite query helpers
  • Framework-agnostic core

Tradeoffs (honestly)

  • Learning curve around query keys and invalidation
  • Server Components reduce its surface area in modern Next.js
  • Bundle size adds up if used trivially

Fit assessment

When to reach for TanStack Query

Pick the right tool for the job.

Best fits

Client-heavy dashboards with frequent fetches

Apps with optimistic UI requirements

Pagination-heavy lists

Real-time-ish data with polling

Mobile-first React apps

Not ideal for

Mostly-static sites with one-shot data

Apps already moved to Server Components for data

Common use cases

Data fetchingCachingOptimistic updatesInfinite queries

Resources

Learn more

Curated official docs, tutorials, and writing on TanStack Query.

Need help with TanStack Query?

Whether you're starting fresh or optimizing an existing implementation, I can help you get the most out of this technology. Read more in insights or get in touch.

Command Palette

Search for a command to run...