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

# Fetch drafts

> Fetch the authenticated user's draft entities

> [!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

`useFetchDrafts` returns a function that retrieves the authenticated user's unpublished draft entities in a paginated response.

> [!NOTE]
>
> Requires an authenticated user. Only the user's own drafts are returned.

## Usage Example

```tsx theme={null}
import { useFetchDrafts } from "@sublay/react-js";
import { useEffect, useState } from "react";

function DraftsList() {
  const fetchDrafts = useFetchDrafts();
  const [drafts, setDrafts] = useState([]);

  useEffect(() => {
    fetchDrafts({ page: 1, limit: 10 }).then((res) => setDrafts(res.data));
  }, []);

  return (
    <ul>
      {drafts.map((d) => (
        <li key={d.id}>{d.title || "Untitled"}</li>
      ))}
    </ul>
  );
}
```

## Parameters

**page** `number`

Page number (1-indexed). Defaults to `1`.

**limit** `number`

Results per page.

**sourceId** `string`

Filter drafts by source ID.

**spaceId** `string`

Filter drafts by space.

**include** `string | string[]`

Populate related fields. Accepted values: `"user"`, `"space"`, `"files"`, `"grants"`. `"topComment"` and `"saved"` are not resolved for drafts.

## Returns

**data** `Entity[]`

Array of draft entities for the current page.

**pagination.page** `number`

Current page number.

**pagination.pageSize** `number`

Number of results per page.

**pagination.totalPages** `number`

Total number of pages.

**pagination.totalItems** `number`

Total count of the user's drafts.

**pagination.hasMore** `boolean`

`true` if there are additional pages available.


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