Skip to main content

Overview

useFetchManySpaces returns a callable function for fetching multiple spaces. It supports searching by name, slug, description, or a combined query; filtering by membership or parent space; and sorting. For paginated, stateful lists with load-more support, use useSpaceList instead.
This is a discovery surface: only public spaces are listed. unlisted and private spaces are excluded for non-members (they stay reachable by direct link/slug). The memberOf=true filter is the exception — it returns the caller’s own spaces regardless of visibility. See Space visibility.

Usage Example

Parameters

page
number
Page number to fetch. Defaults to 1.
limit
number
Number of results per page.
sortBy
string
Sort order: "newest", "oldest", "most_members", or "least_members".
searchSlug
string | null
Filter spaces whose slug contains this value.
searchName
string | null
Filter spaces whose name contains this value.
searchDescription
string | null
Filter spaces whose description contains this value.
searchAny
string | null
Search across name, slug, and description simultaneously.
memberOf
boolean
When true, returns only spaces where the current user is an active member.
parentSpaceId
string | null
Filter to child spaces of a specific parent. Pass null for root-level spaces only.
include
"files" | string[]
Optional. Pass "files" to include avatar file objects in each result.

Returns

data
Space[]
Array of Space objects.
pagination
object
Pagination metadata including page, limit, total, and hasMore.