Skip to main content

Overview

useSpacePermissions is a utility hook that computes derived permission flags from a user’s raw membership permissions and the space’s permission settings. It is used internally by useSpaceData and exposed for cases where you need to compute permissions 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

import { useSpacePermissions } from "@replyke/core";

const permissions = useSpacePermissions({
  memberPermissions: space.memberPermissions,
  postingPermission: space.postingPermission,
  readingPermission: space.readingPermission,
});

console.log(permissions.canPost, permissions.isAdmin);

Parameters

memberPermissions
SpaceMemberPermissions | null | undefined
required
The raw membership permissions object from the space. null or undefined if the user is not a member.
postingPermission
"anyone" | "members" | "admins"
required
The space’s posting permission setting.
readingPermission
"anyone" | "members"
The space’s reading permission setting. Defaults to "anyone".

Returns

isMember
boolean
Whether the user is an active member.
isAdmin
boolean
Whether the user is an admin.
isModerator
boolean
Whether the user is a moderator.
canPost
boolean
Whether the user can post, given the space’s posting permission and their membership status.
canModerate
boolean
Whether the user can moderate content.
canRead
boolean
Whether the user can read content, given the space’s reading permission.
isPending
boolean
Whether the user has a pending membership.
isBanned
boolean
Whether the user is banned.