You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> There's a big difference between "having types" and "being type-safe". This article tries to outline those differences and shows how you can get the best possible type-safety when using React Query together with TypeScript [Read more...](https://tkdodo.eu/blog/type-safe-react-query)
87
+
88
+
## [#20: You Might Not Need React Query](https://tkdodo.eu/blog/you-might-not-need-react-query)
89
+
90
+
> If your application doesn’t rely on client-side data fetching, especially when using frameworks like Next.js or Remix with built-in server components, React Query may be unnecessary. That said, it still shines in hybrid use cases (like infinite scrolling or offline support) where its smart caching and revalidation can be invaluable. [Read more...](https://tkdodo.eu/blog/you-might-not-need-react-query)
91
+
92
+
## [#21: Thinking in React Query](https://tkdodo.eu/blog/thinking-in-react-query)
93
+
94
+
> React Query isn’t a data-fetching library - it's an async state manager designed to treat parameters as dependencies, optimize refetch behavior via `staleTime`, and encourage declarative patterns where `queryKey` drives cache and updates. A small shift in mindset can dramatically streamline how you use React Query. [Read more...](https://tkdodo.eu/blog/thinking-in-react-query)
95
+
96
+
## [#22: React Query and React Context](https://tkdodo.eu/blog/react-query-and-react-context)
97
+
98
+
> React Query lets components independently manage their own data, making them self-sufficient and resilient, but when shared data (like user info fetched higher up) is needed deeper in the tree, React Context can make that implicit dependency explicit and safer. [Read more...](https://tkdodo.eu/blog/react-query-and-react-context)
99
+
100
+
## [#23: Why You Want React Query](https://tkdodo.eu/blog/why-you-want-react-query)
101
+
102
+
> While fetching data with `fetch` inside `useEffect` may seem simple, it quickly gets tangled with bugs like race conditions, missing loading states, stale data, and Strict Mode quirks—making async state management far more complex than it appears. [Read more...](https://tkdodo.eu/blog/why-you-want-react-query)
103
+
104
+
## [#24: The Query Options API](https://tkdodo.eu/blog/the-query-options-api)
105
+
106
+
> React Query v5 introduces a unified "Query Options" API - where all functions like `useQuery`, `invalidateQueries`, and imperative calls accept a single object - simplifying the interface and making reuse across different query contexts much easier while at the same time improving type-safety. [Read more...](https://tkdodo.eu/blog/the-query-options-api)
107
+
108
+
## [#25: Automatic Query Invalidation after Mutations](https://tkdodo.eu/blog/automatic-query-invalidation-after-mutations)
109
+
110
+
> React Query doesn’t automatically tie mutations to queries - but you can leverage "global cache callbacks" in a central `MutationCache` to define shared behaviors like invalidating queries on every mutation. [Read more...](https://tkdodo.eu/blog/automatic-query-invalidation-after-mutations)
111
+
112
+
## [#26: How Infinite Queries work](https://tkdodo.eu/blog/how-infinite-queries-work)
113
+
114
+
> This blog post is a deep dive into how Infinite Queries are designed and work under the hood. Interestingly, there is no distinct InfiniteQuery representation - just a different "behaviour" attached to regular Queries. [Read more...](https://tkdodo.eu/blog/how-infinite-queries-work)
115
+
116
+
## [#27: React Query API Design - Lessons Learned](https://tkdodo.eu/blog/react-query-api-design-lessons-learned)
117
+
118
+
> In this talk, Dominik walks us through some of the API design choices that were made in React Query to get to its arguably good developer experience. You'll hear stories about things that went well, but also about tradeoffs and mistakes that were made, and what lessons we can all learn from those. [Read more...](https://tkdodo.eu/blog/react-query-api-design-lessons-learned)
119
+
120
+
## [#28: React Query - The Bad Parts](https://tkdodo.eu/blog/react-query-the-bad-parts)
121
+
122
+
> In this talk, Dominik explores the less favorable aspects of React Query and situations where it may not be the best fit. No library is perfect; every choice involves trade-offs. By the end of this talk, you'll have a better understanding of React Query's limitations and why it remains a compelling choice despite them. [Read more...](https://tkdodo.eu/blog/react-query-the-bad-parts)
123
+
124
+
## [#29: Concurrent Optimistic Updates in React Query](https://tkdodo.eu/blog/concurrent-optimistic-updates-in-react-query)
125
+
126
+
> Optimistic updates in React Query can cause race conditions when multiple mutations run at once, leading to inconsistent UI states. Cancelling in-flight queries helps, but overlapping invalidations may still overwrite newer updates. [Read more...](https://tkdodo.eu/blog/concurrent-optimistic-updates-in-react-query)
> React Query’s `select` option enables components to subscribe only to the specific part of a query’s data they care about - so updating one field won’t cause unrelated UI to re-render unnecessarily. This fine-grained approach keeps full responses in the cache while optimizing component updates for performance. [Read more...](https://tkdodo.eu/blog/react-query-selectors-supercharged)
Copy file name to clipboardExpand all lines: docs/framework/react/guides/advanced-ssr.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -621,3 +621,11 @@ If you value DX/iteration/shipping speed with low code complexity over performan
621
621
Server Components and streaming are still fairly new concepts and we are still figuring out how React Query fits in and what improvements we can make to the API. We welcome suggestions, feedback and bug reports!
622
622
623
623
Similarly, it would be impossible to teach all the intricacies of this new paradigm all in one guide, on the first try. If you are missing some piece of information here or have suggestions on how to improve this content, also get in touch, or even better, click the "Edit on GitHub" button below and help us out.
624
+
625
+
[//]: #'Materials'
626
+
627
+
## Further reading
628
+
629
+
To understand if your application can benefit from React Query when also using Server Components, have a look at [You Might Not Need React Query](../../community/tkdodos-blog.md#20-you-might-not-need-react-query) from the Community Resources.
Copy file name to clipboardExpand all lines: docs/framework/react/guides/infinite-queries.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -257,3 +257,11 @@ return useInfiniteQuery({
257
257
```
258
258
259
259
[//]: #'Example9'
260
+
[//]: #'Materials'
261
+
262
+
## Further reading
263
+
264
+
To get a better understanding of how Infinite Queries work under the hood, read [How Infinite Queries work](../../community/tkdodos-blog.md#26-how-infinite-queries-work) from
Copy file name to clipboardExpand all lines: docs/framework/react/guides/invalidations-from-mutations.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,3 +37,12 @@ const mutation = useMutation({
37
37
[//]: #'Example2'
38
38
39
39
You can wire up your invalidations to happen using any of the callbacks available in the [`useMutation` hook](../mutations.md)
40
+
41
+
[//]: #'Materials'
42
+
43
+
## Further reading
44
+
45
+
For a technique to automatically invalidate Queries after Mutations, have a look at [Automatic Query Invalidation after Mutations](../../community/tkdodos-blog.md#25-automatic-query-invalidation-after-mutations) from
Copy file name to clipboardExpand all lines: docs/framework/react/guides/optimistic-updates.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -185,3 +185,11 @@ useMutation({
185
185
If you only have one place where the optimistic result should be shown, using `variables` and updating the UI directly is the approach that requires less code and is generally easier to reason about. For example, you don't need to handle rollbacks at all.
186
186
187
187
However, if you have multiple places on the screen that would require to know about the update, manipulating the cache directly will take care of this for you automatically.
188
+
189
+
[//]: #'Materials'
190
+
191
+
## Further reading
192
+
193
+
Have a look at the Community Resources for a guide on [Concurrent Optimistic Updates](../../community/tkdodos-blog.md#29-concurrent-optimistic-updates-in-react-query).
For an in-depth guide about these topics, read [React Query Render Optimizations](../../community/tkdodos-blog.md#3-react-query-render-optimizations) from
76
-
the Community Resources.
76
+
the Community Resources. To learn how to best optimize the `select` option, read [React Query Selectors, Supercharged](../../community/tkdodos-blog.md#30-react-query-selectors-supercharged)
Copy file name to clipboardExpand all lines: docs/framework/react/overview.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,5 +97,6 @@ function Example() {
97
97
98
98
- Consider taking the official [TanStack Query Course](https://query.gg?s=tanstack) (or buying it for your whole team!)
99
99
- Learn TanStack Query at your own pace with our amazingly thorough [Walkthrough Guide](../installation.md) and [API Reference](../reference/useQuery.md)
100
+
- Have a read at [Why You Want React Query](../community/tkdodos-blog.md#23-why-you-want-react-query) from the Community Resources.
Copy file name to clipboardExpand all lines: docs/framework/react/reference/queryOptions.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,3 +22,11 @@ You can generally pass everything to `queryOptions` that you can also pass to [`
22
22
- Defaults to `false`
23
23
- When set to `true`, queries will be prefetched during render, which can be useful for certain optimization scenarios
24
24
- Needs to be turned on for the experimental `useQuery().promise` functionality
25
+
26
+
[//]: #'Materials'
27
+
28
+
## Further reading
29
+
30
+
To learn more about `QueryOptions`, have a look at [The Query Options API](../../community/tkdodos-blog.md#24-the-query-options-api) from the Community Resources.
For tips and tricks around type inference, have a look at [React Query and TypeScript](../community/tkdodos-blog.md#6-react-query-and-typescript) from
265
-
the Community Resources. To find out how to get the best possible type-safety, you can read [Type-safe React Query](../community/tkdodos-blog.md#19-type-safe-react-query).
266
-
267
-
[//]: #'Materials'
259
+
[//]: #'TypingQueryOptions'
268
260
269
261
## Typesafe disabling of queries using `skipToken`
270
262
271
263
If you are using TypeScript, you can use the `skipToken` to disable a query. This is useful when you want to disable a query based on a condition, but you still want to keep the query to be type safe.
272
264
Read more about it in the [Disabling Queries](../guides/disabling-queries.md) guide.
265
+
266
+
[//]: #'Materials'
267
+
268
+
## Further Reading
269
+
270
+
For tips and tricks around type inference, have a look at [React Query and TypeScript](../community/tkdodos-blog.md#6-react-query-and-typescript) from
271
+
the Community Resources. To find out how to get the best possible type-safety, you can read [Type-safe React Query](../community/tkdodos-blog.md#19-type-safe-react-query). [The Query Options API](../community/tkdodos-blog.md#24-the-query-options-api) outlines how type inference works with the `queryOptions` helper function.
0 commit comments