Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

useSuspenseQueries.md

536 lines20.8 KB

1---
2id: useSuspenseQueries
3title: useSuspenseQueries
4---
5​
6## Overview
7​
8```ts
9function useSuspenseQueries<T, TCombinedResult>(options: object, queryClient?: QueryClient): TCombinedResult;
10function useSuspenseQueries<T, TCombinedResult>(options: object, queryClient?: QueryClient): TCombinedResult;
11```
12​
13- [`{ queries, combine }` → `TCombinedResult`](#call-signature-1): The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed` option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.
14- [`{ queries, combine }` → `TCombinedResult`](#call-signature-2): The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed` option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.
15​
16See also: [Parameters](#parameters-summary) · [Returns](#returns-summary)
17​
18<a id="call-signature-1"></a>
19​
20## Call Signature
21​
22```ts
23function useSuspenseQueries<T, TCombinedResult>(options: object, queryClient?: QueryClient): TCombinedResult;
24```
25​
26Defined in: [packages/preact-query/src/useSuspenseQueries.ts:407](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQueries.ts#L407)
27​
28The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed`
29option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.
30​
31### Type Parameters
32​
33#### T
34​
35`T` *extends* `any`[]
36​
37#### TCombinedResult
38​
39`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\<Tails\[K\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\<T\[K\]\> \}
40​
41### Parameters
42​
43#### options
44​
45The `queries` array to run in Suspense, and an optional `combine` function.
46​
47##### combine?
48​
49(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\<T\[K\]\> \}) => `TCombinedResult`
50​
51Use this to combine the results of the queries into a single value. The result will be structurally
52shared to be as referentially stable as possible.
53​
54##### queries
55​
56 \| readonly \[`T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryOptions`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryOptions`\<`Head`\>, `GetUseSuspenseQueryOptions`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : ...[] *extends* \[`...(...)[]`\] ? \[`...(...)[]`\] : ... *extends* ... ? ... : ... : `unknown`[] *extends* `T` ? `T` : `T` *extends* [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] ? [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] : [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly ...[]\>[]\]
57 \| readonly \[\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryOptions\<T\[K\]\> \}\]
58​
59An array with query option objects identical to `useSuspenseQuery`.
60​
61#### queryClient?
62​
63[`QueryClient`](../classes/QueryClient.md)
64​
65Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
66will be used.
67​
68### Returns
69​
70`TCombinedResult`
71​
72The same structure as `useQueries`, except that for each `query`, `data` is guaranteed to be
73defined, `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived
74flags set accordingly).
75​
76Caveat: the component will only re-mount after all queries have finished loading. Hence, if a query has gone
77stale in the time it took for all the queries to complete, it will be fetched again at re-mount. To avoid
78this, make sure to set a high enough `staleTime`. Cancellation does not work.
79​
80### Examples
81​
82The query error is thrown if a fetch fails and no cached data exists yet, so an error boundary is
83required around `<Suspense>`. A failed background refetch instead continues to render the cached data.
84Use [QueryErrorResetBoundary](QueryErrorResetBoundary.md) to let the user retry after such an error:
85```tsx
86import { Suspense } from 'preact/compat'
87import { useErrorBoundary } from 'preact/hooks'
88import {
89 QueryErrorResetBoundary,
90 useSuspenseQueries,
91} from '@tanstack/preact-query'
92import type { ComponentChildren } from 'preact'
93​
94function Posts({ ids }: { ids: Array<number> }) {
95 // Every result is guaranteed to be defined — no per-query `isPending` check needed.
96 const postQueries = useSuspenseQueries({
97 queries: ids.map((id) => ({
98 queryKey: ['post', id],
99 queryFn: () => fetchPost(id),
100 })),
101 })
102​
103 return (
104 <ul>
105 {postQueries.map((query) => (
106 <li key={query.data.id}>{query.data.title}</li>
107 ))}
108 </ul>
109 )
111​
112function App() {
113 return (
114 <QueryErrorResetBoundary>
115 {({ reset }) => (
116 <ErrorBoundary
117 onReset={reset}
118 fallbackRender={({ resetErrorBoundary }) => (
119 <div>
120 There was an error!
121 <button onClick={() => resetErrorBoundary()}>Try again</button>
122 </div>
123 )}
124 >
125 <Suspense fallback={<h1>Loading posts...</h1>}>
126 <Posts ids={[1, 2, 3]} />
127 </Suspense>
128 </ErrorBoundary>
129 )}
130 </QueryErrorResetBoundary>
131 )
133​
134function ErrorBoundary({
135 children,
136 onReset,
137 fallbackRender,
138}: {
139 children: ComponentChildren
140 onReset: () => void
141 fallbackRender: (props: {
142 error: Error
143 resetErrorBoundary: () => void
144 }) => ComponentChildren
145}) {
146 const [error, resetErrorBoundary] = useErrorBoundary(() => onReset())
147​
148 if (error) return fallbackRender({ error, resetErrorBoundary })
149​
150 return children
152```
153​
154Several different queries — use `useSuspenseQueries` instead of multiple `useSuspenseQuery` calls, so
155they fetch in parallel rather than suspending one after another:
156```tsx
157import { Suspense } from 'preact/compat'
158import { useErrorBoundary } from 'preact/hooks'
159import {
160 QueryErrorResetBoundary,
161 useSuspenseQueries,
162} from '@tanstack/preact-query'
163import type { ComponentChildren } from 'preact'
164​
165function Dashboard() {
166 const [usersQuery, teamsQuery, projectsQuery] = useSuspenseQueries({
167 queries: [
168 { queryKey: ['users'], queryFn: fetchUsers },
169 { queryKey: ['teams'], queryFn: fetchTeams },
170 { queryKey: ['projects'], queryFn: fetchProjects },
171 ],
172 })
173​
174 return (
175 <div>
176 <UserList users={usersQuery.data} />
177 <TeamList teams={teamsQuery.data} />
178 <ProjectList projects={projectsQuery.data} />
179 </div>
180 )
182​
183function App() {
184 return (
185 <QueryErrorResetBoundary>
186 {({ reset }) => (
187 <ErrorBoundary
188 onReset={reset}
189 fallbackRender={({ resetErrorBoundary }) => (
190 <div>
191 There was an error!
192 <button onClick={() => resetErrorBoundary()}>Try again</button>
193 </div>
194 )}
195 >
196 <Suspense fallback={<h1>Loading dashboard...</h1>}>
197 <Dashboard />
198 </Suspense>
199 </ErrorBoundary>
200 )}
201 </QueryErrorResetBoundary>
202 )
204​
205function ErrorBoundary({
206 children,
207 onReset,
208 fallbackRender,
209}: {
210 children: ComponentChildren
211 onReset: () => void
212 fallbackRender: (props: {
213 error: Error
214 resetErrorBoundary: () => void
215 }) => ComponentChildren
216}) {
217 const [error, resetErrorBoundary] = useErrorBoundary(() => onReset())
218​
219 if (error) return fallbackRender({ error, resetErrorBoundary })
220​
221 return children
223```
224​
225`combine`s the results into a single boolean, so `Refresh` only re-renders when that boolean changes,
226not on every individual query update. This overload is the only one that accepts `combine`:
227```tsx
228import { Suspense } from 'preact/compat'
229import { useErrorBoundary } from 'preact/hooks'
230import {
231 QueryErrorResetBoundary,
232 useSuspenseQueries,
233} from '@tanstack/preact-query'
234import type { ComponentChildren } from 'preact'
235​
236function Refresh() {
237 const anyFetching = useSuspenseQueries({
238 queries: [
239 { queryKey: ['users'], queryFn: fetchUsers },
240 { queryKey: ['teams'], queryFn: fetchTeams },
241 ],
242 combine: (results) => results.some((result) => result.isFetching),
243 })
244​
245 return anyFetching ? <span>Refreshing…</span> : null
247​
248function App() {
249 return (
250 <QueryErrorResetBoundary>
251 {({ reset }) => (
252 <ErrorBoundary
253 onReset={reset}
254 fallbackRender={({ resetErrorBoundary }) => (
255 <div>
256 There was an error!
257 <button onClick={() => resetErrorBoundary()}>Try again</button>
258 </div>
259 )}
260 >
261 <Suspense fallback={<h1>Loading dashboard...</h1>}>
262 <Refresh />
263 </Suspense>
264 </ErrorBoundary>
265 )}
266 </QueryErrorResetBoundary>
267 )
269​
270function ErrorBoundary({
271 children,
272 onReset,
273 fallbackRender,
274}: {
275 children: ComponentChildren
276 onReset: () => void
277 fallbackRender: (props: {
278 error: Error
279 resetErrorBoundary: () => void
280 }) => ComponentChildren
281}) {
282 const [error, resetErrorBoundary] = useErrorBoundary(() => onReset())
283​
284 if (error) return fallbackRender({ error, resetErrorBoundary })
285​
286 return children
288```
289​
290<a id="call-signature-2"></a>
291​
292## Call Signature
293​
294```ts
295function useSuspenseQueries<T, TCombinedResult>(options: object, queryClient?: QueryClient): TCombinedResult;
296```
297​
298Defined in: [packages/preact-query/src/useSuspenseQueries.ts:584](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQueries.ts#L584)
299​
300The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed`
301option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`.
302​
303### Type Parameters
304​
305#### T
306​
307`T` *extends* `any`[]
308​
309#### TCombinedResult
310​
311`TCombinedResult` = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\<Tails\[K\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\<T\[K\]\> \}
312​
313### Parameters
314​
315#### options
316​
317The `queries` array to run in Suspense, and an optional `combine` function.
318​
319##### combine?
320​
321(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\<T\[K\]\> \}) => `TCombinedResult`
322​
323Use this to combine the results of the queries into a single value. The result will be structurally
324shared to be as referentially stable as possible.
325​
326##### queries
327​
328readonly \[`T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryOptions`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryOptions`\<`Head`\>, `GetUseSuspenseQueryOptions`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...(...)[]`\] *extends* \[...\] ? \[..., ..., ...\] : ... *extends* ... ? ... : ... : `unknown`[] *extends* \[`...Tails[]`\] ? \[`...Tails[]`\] : \[`...(...)[]`\] *extends* ...[] ? ...[] : ...[] : `unknown`[] *extends* `T` ? `T` : `T` *extends* [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] ? [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] : [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[]\]
329​
330An array with query option objects identical to `useSuspenseQuery`.
331​
332#### queryClient?
333​
334[`QueryClient`](../classes/QueryClient.md)
335​
336Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
337will be used.
338​
339### Returns
340​
341`TCombinedResult`
342​
343The same structure as `useQueries`, except that for each `query`, `data` is guaranteed to be
344defined, `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived
345flags set accordingly).
346​
347Caveat: the component will only re-mount after all queries have finished loading. Hence, if a query has gone
348stale in the time it took for all the queries to complete, it will be fetched again at re-mount. To avoid
349this, make sure to set a high enough `staleTime`. Cancellation does not work.
350​
351### Examples
352​
353The query error is thrown if a fetch fails and no cached data exists yet, so an error boundary is
354required around `<Suspense>`. A failed background refetch instead continues to render the cached data.
355Use [QueryErrorResetBoundary](QueryErrorResetBoundary.md) to let the user retry after such an error:
356```tsx
357import { Suspense } from 'preact/compat'
358import { useErrorBoundary } from 'preact/hooks'
359import {
360 QueryErrorResetBoundary,
361 useSuspenseQueries,
362} from '@tanstack/preact-query'
363import type { ComponentChildren } from 'preact'
364​
365function Posts({ ids }: { ids: Array<number> }) {
366 // Every result is guaranteed to be defined — no per-query `isPending` check needed.
367 const postQueries = useSuspenseQueries({
368 queries: ids.map((id) => ({
369 queryKey: ['post', id],
370 queryFn: () => fetchPost(id),
371 })),
372 })
373​
374 return (
375 <ul>
376 {postQueries.map((query) => (
377 <li key={query.data.id}>{query.data.title}</li>
378 ))}
379 </ul>
380 )
382​
383function App() {
384 return (
385 <QueryErrorResetBoundary>
386 {({ reset }) => (
387 <ErrorBoundary
388 onReset={reset}
389 fallbackRender={({ resetErrorBoundary }) => (
390 <div>
391 There was an error!
392 <button onClick={() => resetErrorBoundary()}>Try again</button>
393 </div>
394 )}
395 >
396 <Suspense fallback={<h1>Loading posts...</h1>}>
397 <Posts ids={[1, 2, 3]} />
398 </Suspense>
399 </ErrorBoundary>
400 )}
401 </QueryErrorResetBoundary>
402 )
404​
405function ErrorBoundary({
406 children,
407 onReset,
408 fallbackRender,
409}: {
410 children: ComponentChildren
411 onReset: () => void
412 fallbackRender: (props: {
413 error: Error
414 resetErrorBoundary: () => void
415 }) => ComponentChildren
416}) {
417 const [error, resetErrorBoundary] = useErrorBoundary(() => onReset())
418​
419 if (error) return fallbackRender({ error, resetErrorBoundary })
420​
421 return children
423```
424​
425Several different queries — use `useSuspenseQueries` instead of multiple `useSuspenseQuery` calls, so
426they fetch in parallel rather than suspending one after another:
427```tsx
428import { Suspense } from 'preact/compat'
429import { useErrorBoundary } from 'preact/hooks'
430import {
431 QueryErrorResetBoundary,
432 useSuspenseQueries,
433} from '@tanstack/preact-query'
434import type { ComponentChildren } from 'preact'
435​
436function Dashboard() {
437 const [usersQuery, teamsQuery, projectsQuery] = useSuspenseQueries({
438 queries: [
439 { queryKey: ['users'], queryFn: fetchUsers },
440 { queryKey: ['teams'], queryFn: fetchTeams },
441 { queryKey: ['projects'], queryFn: fetchProjects },
442 ],
443 })
444​
445 return (
446 <div>
447 <UserList users={usersQuery.data} />
448 <TeamList teams={teamsQuery.data} />
449 <ProjectList projects={projectsQuery.data} />
450 </div>
451 )
453​
454function App() {
455 return (
456 <QueryErrorResetBoundary>
457 {({ reset }) => (
458 <ErrorBoundary
459 onReset={reset}
460 fallbackRender={({ resetErrorBoundary }) => (
461 <div>
462 There was an error!
463 <button onClick={() => resetErrorBoundary()}>Try again</button>
464 </div>
465 )}
466 >
467 <Suspense fallback={<h1>Loading dashboard...</h1>}>
468 <Dashboard />
469 </Suspense>
470 </ErrorBoundary>
471 )}
472 </QueryErrorResetBoundary>
473 )
475​
476function ErrorBoundary({
477 children,
478 onReset,
479 fallbackRender,
480}: {
481 children: ComponentChildren
482 onReset: () => void
483 fallbackRender: (props: {
484 error: Error
485 resetErrorBoundary: () => void
486 }) => ComponentChildren
487}) {
488 const [error, resetErrorBoundary] = useErrorBoundary(() => onReset())
489​
490 if (error) return fallbackRender({ error, resetErrorBoundary })
491​
492 return children
494```
495​
496<a id="parameters-summary"></a>
497​
498## Parameters
499​
500### options
501​
502The `queries` array to run in Suspense, and an optional `combine` function.
503​
504#### combine?
505​
506(`result`: `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryResult`\<`Head`\>, `GetUseSuspenseQueryResult`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \{ \[K in string \| number \| symbol\]: GetUseSuspenseQueryResult\<T\[K\]\> \}) => `TCombinedResult`
507​
508Use this to combine the results of the queries into a single value. The result will be structurally
509shared to be as referentially stable as possible.
510​
511#### queries
512​
513readonly \[`T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetUseSuspenseQueryOptions`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...Tails[]`\] *extends* \[`Head`\] ? \[`GetUseSuspenseQueryOptions`\<`Head`\>, `GetUseSuspenseQueryOptions`\<`Head`\>\] : \[`...Tails[]`\] *extends* \[`Head`, `...Tails[]`\] ? \[`...Tails[]`\] *extends* \[\] ? \[\] : \[`...(...)[]`\] *extends* \[...\] ? \[..., ..., ...\] : ... *extends* ... ? ... : ... : `unknown`[] *extends* \[`...Tails[]`\] ? \[`...Tails[]`\] : \[`...(...)[]`\] *extends* ...[] ? ...[] : ...[] : `unknown`[] *extends* `T` ? `T` : `T` *extends* [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] ? [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>[] : [`UseSuspenseQueryOptions`](../interfaces/UseSuspenseQueryOptions.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[]\]
514​
515An array with query option objects identical to `useSuspenseQuery`.
516​
517### queryClient?
518​
519[`QueryClient`](../classes/QueryClient.md)
520​
521Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context
522will be used.
523​
524<a id="returns-summary"></a>
525​
526## Returns
527​
528`TCombinedResult`
529​
530The same structure as `useQueries`, except that for each `query`, `data` is guaranteed to be
531defined, `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived
532flags set accordingly).
533​
534Caveat: the component will only re-mount after all queries have finished loading. Hence, if a query has gone
535stale in the time it took for all the queries to complete, it will be fetched again at re-mount. To avoid
536this, make sure to set a high enough `staleTime`. Cancellation does not work.