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.
Without parentSpaceId (or with parentSpaceId=null) this is a discovery surface: only spaces that are public themselves and have only public spaces above them are listed, for every caller. With parentSpaceId=<id>, the list shows the direct sub-spaces of that space the caller can see that are public or that the caller is an active member of — so an unlisted sub-space appears only to its members, and a private one only to its active members. memberOf=true returns the caller’s own spaces regardless of visibility. See Space visibility.

Usage Example

Parameters

number
Page number to fetch. Defaults to 1.
number
Number of results per page.
string
Sort order: "newest", "members" (most members first), or "alphabetical". Defaults to "members".
string | null
Filter spaces whose slug contains this value.
string | null
Filter spaces whose name contains this value.
string | null
Filter spaces whose description contains this value.
string | null
Search across name, slug, and description simultaneously.
boolean
When true, returns only spaces where the current user is an active member.
string | null
Filter to child spaces of a specific parent. Pass null for root-level spaces only. A specific parent lists the sub-spaces the caller can see that are public or that the caller is an active member of.
"include-all" | "exclude" | "only"
Filter by each space’s nsfwEffective (own flag OR any ancestor). "include-all" (default) adds no predicate; "exclude" drops effective-NSFW spaces; "only" returns only them. Because the filter keys off effective status, "only" may return an NSFW child whose safe parent is omitted — results are not guaranteed to form a contiguous tree. See Space NSFW flagging.
"files" | string[]
Optional. Pass "files" to include avatar file objects in each result.

Returns

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