Skip to main content

Overview

useSpacePermissions is a utility hook that turns a space’s memberPermissions into flat permission flags. Every flag comes from the server’s calculation (see How permissions are calculated); the hook never works them out from the space’s settings. When memberPermissions is missing (for example while the space is loading), every flag is false. It is used internally by useSpaceData and exposed for cases where you need the flags outside of a SpaceProvider.
In most cases, you should use useSpace instead — it exposes isMember, isAdmin, canPost, etc. directly. Use useSpacePermissions only when working outside a SpaceProvider context.

Usage Example

Parameters

SpaceMemberPermissions | null | undefined
required
The space’s memberPermissions, which every single-space fetch returns, for members and non-members alike. null or undefined makes every flag false.
"anyone" | "members" | "team"
required
The space’s posting permission setting. It doesn’t change the flags.
"anyone" | "members"
The space’s reading permission setting. Defaults to "anyone". It doesn’t change the flags.

Returns

boolean
Whether the user is an active member.
boolean
Whether the user is an admin.
boolean
Whether the user is a moderator.
boolean
Whether the user can post entities in the space, as the server reports it.
boolean
Whether the user can moderate content.
boolean
Whether the user can read content in the space, as the server reports it.
boolean
Whether the user has a pending membership.
boolean
Whether the user is banned.