Skip to main content
Spaces can define community rules — titled and optionally described guidelines that are publicly visible to all users. Rules are ordered and can be reordered by admins. They are read-only for regular members.

Fetching Rules

Rules are publicly readable without authentication:
import { useFetchManyRules, useFetchRule } from "@replyke/react-js";

// Fetch all rules for a space
const fetchRules = useFetchManyRules();
const { data: rules, count } = await fetchRules({ spaceId });

// Fetch a single rule by ID
const fetchRule = useFetchRule();
const rule = await fetchRule({ spaceId, ruleId });

Creating Rules

Only space admins can create rules:
import { useCreateRule } from "@replyke/react-js";

const createRule = useCreateRule();
const newRule = await createRule({
  spaceId,
  title: "Be respectful",
  description: "Treat all members with kindness and respect.",
});

Updating and Deleting Rules

import { useUpdateRule, useDeleteRule } from "@replyke/react-js";

const updateRule = useUpdateRule();
const deleteRule = useDeleteRule();

await updateRule({
  spaceId,
  ruleId,
  title: "Updated Title",
  description: "Updated description text.",
});

await deleteRule({ spaceId, ruleId });

Reordering Rules

Admins can reorder rules by providing a new ordered array of rule IDs:
import { useReorderRules } from "@replyke/react-js";

const reorderRules = useReorderRules();
await reorderRules({
  spaceId,
  ruleIds: ["rule-id-1", "rule-id-3", "rule-id-2"],
});
The order field on each rule reflects its position in the list. Rules are typically displayed in ascending order.

Rule Data Shape

Each rule returned by the API has the following fields:
PropertyTypeDescription
idstringUnique rule identifier.
spaceIdstringThe space this rule belongs to.
titlestringShort rule title.
descriptionstring | nullOptional detailed description.
ordernumberSort position within the space’s rule list.
lastApprovedBystring | nullID of the admin who last approved this rule.
createdAtDateCreation timestamp.
updatedAtDateLast update timestamp.

Hook Reference

HookDescription
useFetchManyRulesFetch all rules for a space
useFetchRuleFetch a single rule
useCreateRuleCreate a new rule (admin only)
useUpdateRuleUpdate a rule (admin only)
useDeleteRuleDelete a rule (admin only)
useReorderRulesReorder rules (admin only)