Skip to main content
FieldValue
Package@cometchat/chat-uikit-react
FrameworkReact.js
ComponentsCometChatConversations, CometChatMessageHeader, CometChatMessageList, CometChatMessageComposer
LayoutTwo-panel — conversation list (left) + message view (right)
PrerequisiteComplete React.js Integration Steps 1–5 first
PatternWhatsApp Web, Slack, Microsoft Teams
This guide builds a two-panel chat layout — conversation list on the left, messages on the right. Users tap a conversation to open it. This assumes you’ve already completed React.js Integration (project created, UI Kit installed, init + login working, CSS imported).
Fork the sandbox, insert your CometChat credentials (App ID, Region, Auth Key), and preview the UI in real time.

What You’re Building

Three sections working together:
  1. Sidebar (conversation list) — shows all active conversations (users and groups)
  2. Message view — displays chat messages for the selected conversation in real time
  3. Message composer — text input with support for media, emojis, and reactions

Step 1 — Create the Sidebar Component

Create a CometChatSelector folder inside src/:
src
CometChatSelector
CometChatSelector.tsx
CometChatSelector.css
CometChatSelector.tsx
Key points about the sidebar:
  • CometChatUIKitLoginListener.getLoggedInUser() checks for an active session — the component only renders if a user is logged in.
  • activeConversation highlights the currently selected conversation in the list.
  • onItemClick fires when a user taps a conversation, passing the Conversation object to the parent.

Step 2 — Update App.tsx and App.css

Wire the sidebar and message components together in your main app file.
App.tsx
How it works:
  • When a conversation is tapped, onSelectorItemClicked extracts the User or Group from the Conversation object.
  • selectedUser / selectedGroup state drives which chat is displayed — pass either user or group to the message components, never both.
  • The empty state shows until a conversation is selected.

Step 3 — Run the Project

You should see the conversation list on the left. Tap any conversation to load messages on the right.

Next Steps

Theming

Customize colors, fonts, and styles to match your brand

Components Overview

Browse all prebuilt UI components

React.js Integration

Back to the main setup guide

Core Features

Chat features included out of the box