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

ComponentPurpose
CometChatThreadHeaderDisplays the parent message and reply count at the top of the thread panel
CometChatMessageListRenders threaded replies when given a parentMessageId
CometChatMessageComposerSends replies into the thread with parentMessageId, layout="compact", and enableRichTextEditor

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

Next Steps