Skip to main content

Goal

By the end of this guide you will have a chat interface with a search panel that lets users query messages in a conversation by keyword, displays matching results, and scrolls to a selected message — all using v7 compound components and the CometChat SDK’s MessagesRequestBuilder.

Prerequisites

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

Components Used

Step 1: Set up the chat layout with search state

Start with a full chat layout that includes a conversations sidebar, message panel, and state to control the search panel visibility and the message to jump to. File: App.tsx

Step 2: Create the search panel component

Build a MessageSearchPanel component that accepts a user or group, takes a search keyword, queries messages using MessagesRequestBuilder, and displays the results. File: MessageSearchPanel.tsx

Step 3: Navigate to a selected search result

When the user clicks a search result, pass the message ID to CometChatMessageList via the goToMessageId prop. This scrolls the message list to the matching message and highlights it. File: ChatWithSearch.tsx

Next Steps