Skip to main content

Overview

useCreateRule returns a callable function for creating a new community rule. Only space admins can create rules.

Usage Example

import { useCreateRule } from "@replyke/react-js";

function AddRuleForm({ spaceId }: { spaceId: string }) {
  const createRule = useCreateRule();

  const handleSubmit = async (title: string, description: string) => {
    const rule = await createRule({ spaceId, title, description });
    console.log("Created rule:", rule.id);
  };
}

Parameters

spaceId
string
required
UUID of the space.
title
string
required
Short rule title.
description
string
Optional detailed description for the rule.

Returns

The created Rule object with all fields including the assigned order position.