Skip to main content

Overview

useCreateSpace returns a callable function for creating a new space. The request can include avatar and banner image uploads. The creator is automatically added as an admin.

Usage Example

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

function CreateSpaceForm() {
  const createSpace = useCreateSpace();

  const handleSubmit = async () => {
    const space = await createSpace({
      name: "Design Community",
      slug: "design-community",
      description: "A place for designers to share work and ideas.",
      readingPermission: "anyone",
      postingPermission: "members",
      requireJoinApproval: false,
    });
    console.log("Created:", space.id);
  };
}

Parameters

name
string
required
Display name for the space. 3–100 characters.
slug
string
Optional URL slug. Must be unique per project. Supports letters, numbers, hyphens, and underscores (Unicode allowed).
description
string
Optional description. Up to 1,000 characters.
avatar
{ file: File | Blob; options: UploadImageOptions }
Optional avatar image to upload. The options object controls format, quality, dimensions, and variants.
banner
{ file: File | Blob; options: UploadImageOptions }
Optional banner image to upload.
readingPermission
"anyone" | "members"
Who can read content. Defaults to "anyone".
postingPermission
"anyone" | "members" | "admins"
Who can post entities. Defaults to "members".
requireJoinApproval
boolean
Whether new members must be approved. Defaults to true.
metadata
Record<string, any>
Optional custom metadata. Up to 1 MB.
parentSpaceId
string
Optional UUID of a parent space. The creator must be an admin of the parent space.

Returns

Returns the created Space object.
When creating a child space, all admins and moderators of the parent space are automatically added to the new child space with their same roles.