Goal
By the end of this guide you will have a chat interface with a search panel that lets users find messages in a conversation by keyword and scroll to a selected result โ using the built-inCometChatSearch component instead of building your own search UI.
CometChatSearch already handles the input, debouncing, SDK queries, result rendering, pagination, loading/empty/error states, and keyword highlighting โ so you only wire it to your message list.
Prerequisites
- Completed the Integration Guide
- A running
CometChatProvidersetup with valid credentials - An existing chat screen using
CometChatMessageListandCometChatMessageHeader
Components Used
Step 1: Set up the chat layout with search state
Start with a full chat layout โ a conversations sidebar, message panel, and state to control the search panel visibility and the message to jump to. File: App.tsxStep 2: Scope CometChatSearch to the conversation
CometChatSearch is a complete, self-contained search panel โ thereโs no custom input or result list to build. A few props tailor it to in-conversation message search:
The component handles the search input, debouncing, SDK queries, pagination, and the loading/empty/error states internally. For the full prop list and customization (filter chips, custom result item views, request builders), see the Search component reference.
Step 3: Navigate to a selected search result
When a result is clicked,onMessageClicked gives you the selected message. Pass its ID to CometChatMessageList via the goToMessageId prop โ the list scrolls to the matching message and highlights it.
Reset
goToMessageId to undefined when switching conversations (as in handleConversationClick above) so the list doesnโt try to jump to a message ID from a previous chat.Next Steps
- Search โ full
CometChatSearchreference: filters, scopes, custom result views, and request builders - Message List โ configure message rendering and scroll behavior
- Message Header โ customize header actions and auxiliary views
- Threaded Messages โ add threaded replies to your chat