useQueries

The useQueries hook can be used to fetch a variable number of queries:

const results = useQueries([
{ queryKey: ['post', 1], queryFn: fetchPost },
{ queryKey: ['post', 2], queryFn: fetchPost },
])

Note that if any query in the array of query option objects is configured with suspense: true or useQueryBoundary: true, that configuration will apply to all queries handled by that useQueries hook.

Options

The useQueries hook accepts an array with query option objects identical to the useQuery hook.

Returns

The useQueries hook returns an array with all the query results.

Was this page helpful?

Resources

Subscribe to our newsletter

The latest TanStack news, articles, and resources, sent to your inbox.

    I won't send you spam.

    Unsubscribe at any time.

    © 2020 Tanner Linsley. All rights reserved.