TanStack
自动

TanStackQuery

强大 (Powerful) 异步状态管理 (asynchronous state management) 适用于 TS/JS, React, Solid, Vue, Svelte 和 Angular (for TS/JS, React, Solid, Vue, Svelte and Angular)

抛弃那些细粒度的状态管理、手动重新获取和无尽的异步意大利面条代码吧。TanStack Query 为您提供声明式、始终最新的自动管理查询和变更,它们 (Toss out that granular state management, manual refetching and endless bowls of async-spaghetti code. TanStack Query gives you declarative, always-up-to-date auto-managed queries and mutations that) 直接改善您的开发者和用户体验 (directly improve both your developer and user experiences).

阅读文档 (Read the Docs)

(或查看我们的官方课程 👇) (or check out our official course 👇)

声明式 & 自动化 (Declarative & Automatic)

手动编写数据获取逻辑已经过时了。告诉 TanStack Query 在哪里获取您的数据以及您需要它有多新鲜,剩下的就都是自动的了。它处理 (Writing your data fetching logic by hand is over. Tell TanStack Query where to get your data and how fresh you need it to be and the rest is automatic. It handles) 开箱即用的缓存、后台更新和过时数据,无需任何配置 (caching, background updates and stale data out of the box with zero-configuration).

简单 & 易用 (Simple & Familiar)

如果您知道如何使用 Promise 或 async/await,那么您已经知道如何使用 TanStack Query 了。没有 (If you know how to work with promises or async/await, then you already know how to use TanStack Query. There's) 无需管理全局状态、reducer、规范化系统或理解繁重的配置。只需传递一个解析您的数据(或抛出错误)的函数,剩下的就交给历史吧。(no global state to manage, reducers, normalization systems or heavy configurations to understand. Simply pass a function that resolves your data (or throws an error) and the rest is history.)

可扩展 (Extensible)

TanStack Query 可配置到查询的每个观察者实例,具有适合各种用例的旋钮和选项。它预装了 (TanStack Query is configurable down to each observer instance of a query with knobs and options to fit every use-case. It comes wired up with) 专用开发工具、无限加载 API 和一流的变更工具,让更新您的数据变得轻而易举。不过别担心,一切都已预先配置为成功!(dedicated devtools, infinite-loading APIs, and first class mutation tools that make updating your data a breeze. Don't worry though, everything is pre-configured for success!)

无依赖。功能齐全。(No dependencies. All the Features.)

TanStack Query 零依赖,鉴于它提供的密集功能集,它非常精简。从周末爱好到企业级电子商务系统(是的,我正在看着你,沃尔玛!😉),TanStack Query 是久经考验的工具,可帮助您以您的创造力速度取得成功。(With zero dependencies, TanStack Query is extremely lean given the dense feature set it provides. From weekend hobbies all the way to enterprise e-commerce systems (Yes, I'm lookin' at you Walmart! 😉), TanStack Query is the battle-hardened tool to help you succeed at the speed of your creativity.)

后端无关 专用开发工具 自动缓存 自动重新获取 窗口聚焦时重新获取 轮询/实时查询 并行查询 依赖查询 变更 API 自动垃圾回收 分页/游标查询 加载更多/无限滚动查询 滚动恢复 请求取消 支持 Suspense! 边获取边渲染 预取 变长并行查询 离线支持 SSR 支持 数据选择器
受生产环境信任
GoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUberGoogleWalmartFacebookPayPalAmazonAmerican ExpressMicrosoftTargetEbayAutodeskCarFAXDocusignHPMLBVolvoOcadoUPC.chEFI.comReactBricksNozzle.ioUber
这个广告帮助我们对投入的时间感到高兴,而不是精疲力尽并怒而退出开源项目。耶!钱! 😉

更少的代码,更少的边缘情况。

与其编写 reducers、缓存逻辑、计时器、重试逻辑、复杂的 async/await 脚本(我可以继续列举...),不如说您只需编写通常所需代码的一小部分。当您使用 TanStack Query 时,您会惊讶于自己编写的代码如此之少,或者删除了多少代码。通过下面的示例之一尝试一下吧!

哇,您已经走了很长一段路!
只剩下一件事要做...