> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Publish draft

> Publish a draft entity, making it publicly visible

<Note>
  **Requires the `entities` bundle.** A project without the entities bundle returns `403 database/tables-not-available`. See [Bundles](/v8/bundles).
</Note>

## 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

```tsx theme={null}
import { usePublishDraft } from "@sublay/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

<ParamField path="entityId" type="string" required>
  The ID of the draft entity to publish.
</ParamField>

## Returns

<ResponseField name="Entity" type="Entity">
  The published entity with `isDraft: false`. See [Entity data model](/v8/data-models/entity).
</ResponseField>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.