Skip to main content

Overview

usePublishDraft returns a function that publishes a draft entity. After publishing, entity.isDraft becomes false and the entity is visible to other users.

Usage Example

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

function PublishButton({ entityId }: { entityId: string }) {
  const publishDraft = usePublishDraft();

  const handlePublish = async () => {
    const entity = await publishDraft({ entityId });
    console.log("Published, isDraft:", entity.isDraft); // false
  };

  return <button onClick={handlePublish}>Publish</button>;
}

Parameters

entityId
string
required
The ID of the draft entity to publish.

Returns

Entity
Entity
The published entity with isDraft: false. See Entity data model.