Skip to main content

useSuspenseQueries

The useSuspenseQueries hook is a Suspense-enabled version of useQueries. It suspends rendering until all queries have data and always returns data (never undefined).

Import

Signature

Type Parameters

type
Array type representing the queries configuration
type
default:"SuspenseQueriesResults<T>"
The type of the combined result when using the combine option

Parameters

object
required
Configuration object for the queries
readonly [...SuspenseQueriesOptions<T>]
required
An array of query options. Each query in the array accepts the same options as useSuspenseQuery.
(result: SuspenseQueriesResults<T>) => TCombinedResult
Optional function to combine or select data from all queries. This function is called whenever any query updates.
QueryClient
Optional QueryClient instance to use. If not provided, the context client is used.

Returns

Returns an array of query results (one for each query), or the result of the combine function if provided. Each query result has the same shape as useSuspenseQuery results:
TData
required
The data for the query. Always defined (never undefined) for suspense queries.
null
Always null for suspense queries (errors are thrown to error boundaries)
'success'
Always 'success' for suspense queries
true
Always true for suspense queries
false
Always false for suspense queries
false
Always false for suspense queries

Examples

Basic Usage

With Combine Function

Dynamic Queries

With Error Boundary and Suspense

Notes

  • skipToken cannot be used with any of the queries in useSuspenseQueries. If you need conditional fetching, use useQueries instead.
  • The component will suspend until all queries have loaded their initial data.
  • If any query errors, the error is thrown to the nearest error boundary.
  • All queries are run in parallel.
  • The enabled option is always set to true for all queries and cannot be disabled.