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
CometChatProvidersetup with valid credentials - An existing chat screen using
CometChatMessageListandCometChatMessageComposer
Components Used
Step 1: Thread State Management
Store thethreadedMessage 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 theonThreadRepliesClick 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
WhenthreadedMessage 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 theonParentDeleted 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.tsxThread 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.
Reacting to changes
PassonThreadSubscriptionChange to the thread header to run your own logic when the user subscribes or unsubscribes:
Hiding the controls
hideThreadSubscriptionToggleonCometChatThreadHeaderremoves the bell.hideThreadSubscriptionOptiononCometChatMessageListremoves the context-menu option.
Driving it yourself
For custom UI, theuseThreadSubscription hook exposes the same state and toggle:
ui:thread/subscription-changed (the optimistic local flip) and thread/subscription-changed (the server acknowledgement).
Next Steps
- Thread Header — customize the thread header appearance
- Message List — configure message list rendering and options
- CometChatProvider — learn about provider configuration