Documentation Index Fetch the complete documentation index at: https://cometchat-22654f5b-react-uikit-v7.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
Field Value Package @cometchat/chat-uikit-reactFramework React.js Components CometChatMessageHeader, CometChatMessageList, CometChatMessageComposerLayout Single chat window — no sidebar, no conversation list Prerequisite Complete React.js Integration first Pattern Support chat, embedded widgets, focused messaging
This guide builds a single chat window — no sidebar, no conversation list. Users go directly into a one-to-one or group chat. Good for support chat, embedded widgets, or any focused messaging experience.
This assumes you’ve already completed React.js Integration (project created, UI Kit installed, init + login working).
What You’re Building
Three components stacked vertically:
Chat header — displays recipient name, avatar, online status, and optional call buttons
Message list — real-time chat history with scrolling
Message composer — text input with media, emojis, and reactions
Full Code
Replace your src/App.tsx with the following. This assumes init() and login() already happen in src/main.tsx (as shown in the integration guide).
import { useEffect , useState } from "react" ;
import { CometChat } from "@cometchat/chat-sdk-javascript" ;
import {
CometChatProvider ,
CometChatMessageHeader ,
CometChatMessageList ,
CometChatMessageComposer ,
} from "@cometchat/chat-uikit-react" ;
import "@cometchat/chat-uikit-react/styles" ;
import "./App.css" ;
const RECIPIENT_UID = "cometchat-uid-2" ; // Replace with the UID you want to chat with
function App () {
const [ chatUser , setChatUser ] = useState < CometChat . User | undefined >( undefined );
useEffect (() => {
CometChat . getUser ( RECIPIENT_UID ). then (
( user ) => setChatUser ( user ),
( error ) => console . error ( "User fetch failed:" , error )
);
}, []);
if ( ! chatUser ) return < div > Loading chat... </ div > ;
return (
< CometChatProvider >
< div className = "chat-window" >
< CometChatMessageHeader user = { chatUser } />
< CometChatMessageList user = { chatUser } />
< CometChatMessageComposer user = { chatUser } />
</ div >
</ CometChatProvider >
);
}
export default App ;
.chat-window {
display : flex ;
flex-direction : column ;
height : 100 vh ;
width : 100 % ;
}
Key points:
CometChat.getUser(UID) fetches the full user object from the SDK — you need a real user object, not a manually constructed one.
Pass either user or group to the message components, never both.
The RECIPIENT_UID should be a user that exists in your CometChat app. Use one of the pre-created test UIDs: cometchat-uid-1 through cometchat-uid-5.
Switching to Group Chat
To load a group chat instead of one-to-one, fetch a Group object and pass it to the message components:
import { useEffect , useState } from "react" ;
import { CometChat } from "@cometchat/chat-sdk-javascript" ;
import {
CometChatProvider ,
CometChatMessageHeader ,
CometChatMessageList ,
CometChatMessageComposer ,
} from "@cometchat/chat-uikit-react" ;
import "@cometchat/chat-uikit-react/styles" ;
import "./App.css" ;
const GROUP_ID = "cometchat-guid-1" ; // Replace with your Group ID
function App () {
const [ chatGroup , setChatGroup ] = useState < CometChat . Group | undefined >( undefined );
useEffect (() => {
CometChat . getGroup ( GROUP_ID ). then (
( group ) => setChatGroup ( group ),
( error ) => console . error ( "Group fetch failed:" , error )
);
}, []);
if ( ! chatGroup ) return < div > Loading chat... </ div > ;
return (
< CometChatProvider >
< div className = "chat-window" >
< CometChatMessageHeader group = { chatGroup } />
< CometChatMessageList group = { chatGroup } />
< CometChatMessageComposer group = { chatGroup } />
</ div >
</ CometChatProvider >
);
}
export default App ;
The only difference: use CometChat.getGroup(GUID) instead of CometChat.getUser(UID), and pass group instead of user.
Run
Open http://localhost:5173. You should see the chat window load with the conversation for the UID or GUID you set.
Next Steps
Conversation List + Messages Two-panel layout with a sidebar
Tab-Based Chat Tabbed navigation with Chats, Calls, Users
Components Overview Browse all prebuilt UI components