Skip to main content

Overview

useSpace returns the current space state and all operations from the nearest SpaceProvider. It is the primary way to interact with a space in your component tree.
This hook must be used inside a SpaceProvider.

Usage Example

Returns

SpaceDetailed | null | undefined
The loaded space. undefined while loading, null if not found.
boolean
true while fetching the space.
string | null
Error message if the fetch failed.
boolean
true if the current user has an active membership.
boolean
true if the current user is a space admin.
boolean
true if the current user is a space moderator.
boolean
true if the current user can post entities in this space.
boolean
true if the current user can perform moderation actions.
"pending" | "active" | "banned" | null
Raw membership status. null if not a member.
boolean
true if the user’s join request is awaiting approval.
boolean
true if the user is banned from this space.
SpacePreview[]
Ancestor spaces from root to direct parent. Empty for root spaces.
SpacePreview | null
Preview of the parent space. null for root spaces.
SpacePreview[]
Previews of direct child spaces (up to 10).
() => Promise<void>
Join the space. Creates a pending membership when approval is required.
() => Promise<void>
Leave the space.
(props: { update }) => Promise<SpaceDetailed | undefined>
Update space settings (admin only).
() => Promise<void>
Delete the space (admin only).
React.Dispatch
Directly update the space state for optimistic UI updates.
For integration guidance, see SpaceProvider & useSpace.