Ali SadeghiPortfolio detail page
Go to Ali's portfolio

TanStack Query

Server State & Async Data

Used TanStack Query to simplify server-state management in React projects, handling fetching, caching, loading, errors, refetching, and asynchronous data flows with much less manual state management.

TanStack Query logo

Where It Helps

  • Managing server state and asynchronous data inside React applications
  • Handling caching, loading, errors, refetching, and request lifecycle without repetitive manual state logic
  • Keeping API-driven components cleaner and separating server state from regular application state

Story

I came across TanStack Query relatively late, in 2026, after I had already spent a lot of time working with REST APIs, fetch, and Axios.

By that point, I had already experienced what it was like to manage asynchronous data manually, so when I started using TanStack Query and useQuery, its value made sense to me almost immediately.

What I liked wasn't just that it reduced the amount of code.

The mental model also made a lot of sense to me: treating server state as something different from normal application state and giving it its own tools for fetching, caching, refetching, and keeping data in sync.

I practiced it more seriously while building React Mastery Loop AI, one of the projects I created to keep my React skills fresh and explore tools I hadn't used much before.

I think you need to work without something like TanStack Query for a while to really appreciate it.

You need to manually handle loading, errors, data, retries, request timing, and the state changes around fetch calls at least once to understand how much work tools like Axios and especially TanStack Query can handle for you.

My experience with it still isn't as deep as something like React or Axios, but I really like the way it approaches server state.

If I'm building a React application with a lot of API-driven data today, TanStack Query is one of the first tools I'd consider using.

Ask ChatGPT

Get a summary or ask questions about this page.

Open in ChatGPT