useSpaceList hook provides a Redux-backed, paginated list of spaces with support for filtering, sorting, and search. It lists the space directory, for discovery and browse pages. For the spaces the current user is a member of, see My spaces below.
Basic Usage
Filtering and Sorting
parentSpaceId: "none" on every page, including loadMore and a re-sort, until you name a parent or "any".
Sort Options
Pass
sortDir: "asc" or "desc" to reverse any of them, for example fetchSpaces({ sortBy: "createdAt", sortDir: "asc" }) for oldest first. Left out, each sort uses the direction above.
Creating and Deleting from a List
useSpaceList also exposes create and delete operations that automatically update the list state:
Multiple Independent Lists
EachuseSpaceList call uses a listId to maintain independent Redux state. You can have multiple lists on the same page without interference:
My Spaces
Across levels (parentSpaceId "none" or "any"), a space list includes a space only if it and every space above it are public. Under one parent (a space id), it includes the sub-spaces the user can see that are public or that they’re an active member of — the same ones the parent’s childSpaces preview shows and its childSpacesCount counts. For a “my spaces” screen, use useFetchUserSpaces: it lists the spaces the current user is a member of, whatever their visibility, with their membership on each, and takes its own query, searchFields, sortBy ("joinedAt", the default, "createdAt", "members" or "alphabetical") and sortDir.
It also takes parentSpaceId: "none" for the user’s memberships in top-level spaces only, or a space id for their memberships in that space’s direct sub-spaces. "any", left out or null: memberships at every level (the default, because membership is per space). "none" goes by where the space sits, not by what the user belongs to: a membership in a sub-space whose parent the user isn’t in is not top-level, so "none" leaves it out.
Return Values
Space[]
The current page of loaded spaces.
boolean
true while fetching.boolean
true if there are more pages to load.function
Trigger a new fetch with the given filters and configuration. Resets to page 1.
function
Fetch the next page of results and append to the current list.
function
Create a new space and insert it into the list.
function
Delete a space and remove it from the list.

