Skip to main content

Goal

By the end of this guide you will have a chat interface where users can open a thread panel from any message, view the parent message with its reply count, browse threaded replies, and send new replies — all using v7 compound components and a state-based approach (no custom events needed).

Prerequisites

  • Completed the Integration Guide guide
  • A running CometChatProvider setup with valid credentials
  • An existing chat screen using CometChatMessageList and CometChatMessageComposer

Components Used

Step 1: Thread State Management

Store the threadedMessage in state. When set, the thread panel renders. When cleared, it closes. This mirrors the pattern used in the sample app’s CometChatThreadPanel component. File: ChatWithThreads.tsx

Step 2: Wire the Thread Trigger

Use the onThreadRepliesClick callback on CometChatMessageList to capture when a user clicks “Reply in Thread.” This sets the threaded message and opens the panel — no events required. File: ChatWithThreads.tsx

Step 3: Build the Thread Panel

When threadedMessage is set, render a side panel composing CometChatThreadHeader + CometChatMessageList (with parentMessageId) + CometChatMessageComposer (with parentMessageId, layout="compact", and enableRichTextEditor). The onClose callback clears the state to dismiss the panel. File: ChatWithThreads.tsx

Step 4: Handle Parent Deleted

Use the onParentDeleted prop on CometChatThreadHeader to automatically close the thread panel when the parent message is deleted by another user or a moderation action. File: ChatWithThreads.tsx

Complete Example

File: App.tsx

Thread Subscription

In a group thread, users can subscribe to the thread to keep getting updates about new replies even when they aren’t actively viewing it, and unsubscribe to stop. The UI Kit surfaces this in two places, both wired out of the box:
  • A bell toggle in CometChatThreadHeader (group threads only — it never appears in a 1:1 thread).
  • A subscribe / unsubscribe option in the message context menu of CometChatMessageList.
Both reflect the current subscription state, flip it optimistically on click, and show a toast if the server rejects the change. No wiring is required to make them work.

Reacting to changes

Pass onThreadSubscriptionChange to the thread header to run your own logic when the user subscribes or unsubscribes:

Hiding the controls

Driving it yourself

For custom UI, the useThreadSubscription hook exposes the same state and toggle:
Subscription changes are also broadcast on the event bus: ui:thread/subscription-changed (the optimistic local flip) and thread/subscription-changed (the server acknowledgement).

Next Steps