{
 "kind": "tool",
 "slug": "tanstack-react-query",
 "path": "tools/tanstack-react-query/",
 "name": "TanStack Query",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "State and data fetching",
   "tools/state-data/"
  ]
 ],
 "lead": "Hooks for managing, caching and synchronizing remote data in React.",
 "chips": [
  {
   "label": "State and data fetching",
   "path": "tools/state-data/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install @tanstack/react-query"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/TanStack/query"
  },
  {
   "label": "Website",
   "href": "https://tanstack.com/query"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from npm.",
   "src": "https://github.com/TanStack/query"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 24, 2026",
   "note": "Latest GitHub release Nov 23, 2026. ",
   "src": "https://github.com/TanStack/query"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "458 projects",
   "status": "info",
   "sub": "#1 of 53 in its category",
   "note": "Dependency in 458 public GitHub projects set up for AI coding agents that we scanned (7.3%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Docs for agents",
   "status": "yes",
   "sub": "llms.txt",
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": "https://tanstack.com/llms.txt"
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What TanStack Query does",
   "parts": [
    {
     "t": "prose",
     "text": "TanStack Query treats server data as a cache with a four-step lifecycle (fetch, share, revalidate, collect). Components declare a key and the data they need, and the cache coordinates the fetches."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "TanStack Query popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "88",
       "of": "/ 100",
       "l": "Gid Score, #15 overall"
      },
      {
       "n": "92M",
       "l": "downloads a week, npm"
      },
      {
       "n": "50.6K",
       "l": "GitHub stars"
      },
      {
       "n": "458",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How TanStack Query is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "TanStack Query is a dependency in 458 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (9.4% of the 4,867 JavaScript/TypeScript ones), #1 of 53 in state and data fetching.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 2,243; those are left out of every share on this page.",
      "The most used alternative in our scan is SWR (51 projects).",
      "Projects that use it most often also use Lucide React (77.5%), Tailwind Merge (74.9%), clsx (76.4%).",
      "It is more common in projects set up for Roo Code (14.4%) than for Gemini CLI (6.1%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "241 projects, 9.9%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "228 projects, 7.0%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "197 projects, 6.5%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "40 projects, 8.5%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "30 projects, 10.8%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "29 projects, 6.1%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "26 projects, 7.6%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "16 projects, 14.4%",
       "v": "Roo Code",
       "path": "agents/roo-code/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 77.5% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      },
      {
       "l": "In 74.9% of its projects",
       "v": "Tailwind Merge",
       "path": "tools/tailwind-merge/"
      },
      {
       "l": "In 76.4% of its projects",
       "v": "clsx",
       "path": "tools/clsx/"
      },
      {
       "l": "In 98.5% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 70.5% of its projects",
       "v": "Class Variance Authority",
       "path": "tools/class-variance-authority/"
      },
      {
       "l": "In 62.2% of its projects",
       "v": "Radix UI",
       "path": "tools/radix-ui/"
      },
      {
       "l": "In 77.3% of its projects",
       "v": "Zod",
       "path": "tools/zod/"
      },
      {
       "l": "In 88.6% of its projects",
       "v": "Tailwind CSS",
       "path": "tools/tailwindcss/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "TanStack Query in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Same key, one request",
       "v": "The site says components that ask for the same key share one cache entry. In its words, every observer reads that entry \"instead of issuing another request.\""
      },
      {
       "l": "Retries and focus refetching come wired, the site says",
       "v": "Under the heading \"Deadly defaults,\" the site lists caching, request deduplication, retries, background refetching, window-focus updates and garbage collection as already set up."
      },
      {
       "l": "Dependent queries, prefetching and Suspense are on the feature list",
       "v": "The README lists mutations, dependent queries, background updates, prefetching, cancellation and React Suspense support. It also lists pagination and infinite scroll."
      },
      {
       "l": "A docs router written for agents",
       "v": "TanStack publishes a root <code>llms.txt</code> that points agents to a separate docs index for each product. Query has its own index. The root file says to fetch the linked product docs index first, then follow links from there for deeper context."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Stale values stay on screen during a refresh",
       "v": "The site says \"Stale data can remain valuable\" and that stale data stays visible while a background request refreshes it."
      },
      {
       "l": "Unused entries are removed, timing not stated here",
       "v": "The site says data with no observers stays available \"briefly\" before garbage collection removes it. These pages do not say how long \"briefly\" is."
      },
      {
       "l": "Writes are explicit",
       "v": "The site says the parts of a write \"stay explicit.\" Its sample mutation outline shows four parts: an optimistic <code>setQueryData</code>, the awaited server call, a targeted <code>invalidateQueries</code>, and an <code>onError</code> rollback."
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about TanStack Query",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/tannerlinsley",
        "GitHub Sponsors: https://github.com/TkDodo",
        "158 GitHub sponsors"
       ]
      },
      {
       "title": "Head to head",
       "items": [
        {
         "text": "TanStack Query vs SWR",
         "note": "used together in 14 projects",
         "path": "tools/compare/tanstack-query-vs-swr/"
        }
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "class-variance-authority: Variant class names",
        "tailwind-merge: Tailwind class merging",
        "clsx: Conditional class names",
        "react: UI library",
        "@radix-ui: UI primitives",
        "lucide-react: Icons"
       ]
      },
      {
       "title": "More in State and data fetching",
       "path": "tools/state-data/",
       "items": [
        {
         "text": "Zustand",
         "path": "tools/zustand/"
        },
        {
         "text": "RxJS",
         "path": "tools/rxjs/"
        },
        {
         "text": "Pinia",
         "path": "tools/pinia/"
        },
        {
         "text": "nuqs",
         "path": "tools/nuqs/"
        },
        {
         "text": "Immer",
         "path": "tools/immer/"
        },
        {
         "text": "React Redux",
         "path": "tools/react-redux/"
        },
        {
         "text": "Redux Toolkit",
         "path": "tools/reduxjs/"
        },
        {
         "text": "Jotai",
         "path": "tools/jotai/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "TanStack Query",
       "me": true,
       "facts": [
        "MIT",
        "Gid 88",
        "92M/wk"
       ]
      },
      {
       "name": "SWR",
       "why": "React hooks library for data fetching with caching, revalidation and real-time updates.",
       "path": "tools/swr/",
       "facts": [
        "MIT",
        "Gid 77",
        "28.5M/wk"
       ]
      }
     ],
     "more": "Compare TanStack Query with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install @tanstack/react-query"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## TanStack Query\n- Declare data in components with `useQuery()` and an array query key. The site's examples use keys such as `['issues', 'router-cache']` and `['issues', 'project-detail']`.\n- Before writing your own request deduplication, retries, background refetching, window-focus updates or garbage collection, check the defaults. The site says these \"arrive wired.\"\n- Keep the query function to resolving data. The site says Query owns cancellation, retries and deduplication around it.\n- Expect stale data to stay visible while a background request refreshes it. The site says stale data \"can remain valuable.\"\n- For optimistic updates, follow the shape of the site's sample mutation outline: `setQueryData(['todos'], next)`, then `await saveTodo(todo)`, then a targeted `invalidateQueries({ queryKey: ['todos'] })`, with a rollback path in `onError`.\n- For docs, start from `https://tanstack.com/llms.txt`. It links the Query docs index at `https://tanstack.com/query/latest/llms.txt`. The root file says to fetch the linked product docs index first and follow links from that page only when you need deeper context.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm @tanstack/react-query"
  ],
  [
   "Category",
   "State and data fetching"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "release-2026-10-02-1005, October 2, 2026"
  ],
  [
   "On GitHub since",
   "September 2019"
  ],
  [
   "Gid Score",
   "88.1"
  ],
  [
   "Rank in category",
   "#1 of 53"
  ],
  [
   "GitHub",
   "TanStack/query"
  ],
  [
   "Last change",
   "Nov 24, 2026"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/tanstack.png"
}