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

# Use total unread count

> Get the total number of unread messages across all conversations

## Overview

Returns the total count of unread messages across all of the current user's conversations. This value is fetched from the server on `ChatProvider` mount and kept in sync via socket events as new messages arrive.

> [!NOTE]
>
> Requires `ChatProvider` in the component tree.

## Usage Example

```tsx theme={null}
import { useTotalUnreadCount } from "@sublay/react-js";

function ChatNavItem() {
  const unread = useTotalUnreadCount();

  return (
    <div className="relative">
      <ChatIcon />
      {unread > 0 && (
        <span className="badge">{unread > 99 ? "99+" : unread}</span>
      )}
    </div>
  );
}
```

## Returns

**number** `number`

Total unread message count. Returns `0` before the first fetch completes.

## Notes

* This count is accurate before the conversation list is ever loaded — useful for showing a badge in navigation without requiring the user to visit the chat screen first.
* For integration guidance, see [Chat: Real-time](https://docs.sublay.io/v7/sdk/chat/real-time.md).


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