AI Integration Quick Reference
AI Integration Quick Reference
| Field | Value |
|---|---|
| Package | @cometchat/chat-uikit-react |
| Framework | Astro |
| Components | CometChatMessageHeader, CometChatMessageList, CometChatMessageComposer |
| Layout | Single chat window — no sidebar, no conversation list |
| Prerequisite | Complete Astro Integration first |
| SSR | React island with client:only="react" directive |
| Pattern | Support chat, embedded widgets, focused messaging |

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
Create a React island component with the chat UI, then render it in an Astro page withclient:only="react".
src/components/DirectChat.tsx
src/pages/chat.astro
client:only="react"ensures the component only runs in the browser — no server-side rendering.CometChat.getUser(UID)fetches the full user object from the SDK — you need a real user object, not a manually constructed one.- Pass either
userorgroupto the message components, never both. - The
RECIPIENT_UIDshould be a user that exists in your CometChat app. Use one of the pre-created test UIDs:cometchat-uid-1throughcometchat-uid-5.
Switching to Group Chat
To load a group chat instead of one-to-one, fetch aGroup object and pass it to the message components:
src/components/DirectChat.tsx
CometChat.getGroup(GUID) instead of CometChat.getUser(UID), and pass group instead of user.
Run
http://localhost:4321/chat. 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