> ## 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](https://docs.sublay.io/v7/bundles.md).

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

**entityId** `string` *required*

The ID of the draft entity to publish.

## Returns

**Entity** `Entity`

The published entity with `isDraft: false`. See [Entity data model](https://docs.sublay.io/v7/data-models/entity.md).


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