Skip to main content

Overview

Returns the number of conversations that have at least one unread message. This value is fetched from the server on ChatProvider mount and kept in sync via socket events.
Requires ChatProvider in the component tree.

Usage Example

import { useUnreadConversationCount } from "@sublay/react-js";

function InboxBadge() {
  const count = useUnreadConversationCount();

  return (
    <div>
      Inbox {count > 0 && <span>({count})</span>}
    </div>
  );
}

Returns

number
number
Number of conversations with at least one unread message. Returns 0 before the first fetch completes.

Notes

  • When an event touches a conversation not currently loaded in the list (e.g. paginated out), this count reconciles automatically against the server’s authoritative unread summary — no remount required. It also reconciles on socket reconnect.
  • To get the total number of unread messages (not conversations), use useTotalUnreadCount.
  • For integration guidance, see Chat: Real-time.