AI Integration Quick Reference
AI Integration Quick Reference

What You’re Building
Three sections working together:- Sidebar (conversation list) — shows all active conversations (users and groups)
- Message view — displays chat messages for the selected conversation in real time
- Message composer — text input with support for media, emojis, and reactions
Full Code
Replace yoursrc/App.tsx with the following. Init and login must complete before the provider mounts — see the React.js Integration guide for the src/main.tsx setup.
src/App.tsx
src/App.css
How It Works
- CometChatProvider wraps the entire tree — it supplies theme, locale, and event context to all CometChat components.
- CometChatConversations renders the sidebar list. When a user clicks a conversation,
onItemClickfires with theConversationobject. - handleConversationClick extracts the
UserorGroupfrom the conversation and stores it in state. - Message components (
MessageHeader,MessageList,MessageComposer) receive eitheruserorgroupas a prop — never both at the same time. - When the user switches conversations, state updates and the message panel re-renders with the new chat.
- Active highlight — the selected conversation is passed back to the list as
activeConversation, so the open row stays highlighted while its chat is on screen. - Details panel round-trip — clicking the message header opens a group details / members side panel (
CometChatGroupMembers). ItsonBacksetsshowDetailsback tofalseto close it — the full open→close cycle for the side panel, not just opening it.
Run
http://localhost:5173. You should see the conversation list on the left. Click any conversation to load messages on the right.
Next Steps
One-to-One / Group Chat
Single chat window without a sidebar
Tab-Based Chat
Tabbed navigation with Chats, Calls, Users
Components Overview
Browse all prebuilt UI components
Theming
Customize colors, fonts, and styles