diff --git a/.gitignore b/.gitignore index 96adadbc8..febf5f018 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store .kiro/ +/cometchat-uikit-react-6 diff --git a/fundamentals/extensions-overview.mdx b/fundamentals/extensions-overview.mdx index d6e58d1dd..3aa338a73 100644 --- a/fundamentals/extensions-overview.mdx +++ b/fundamentals/extensions-overview.mdx @@ -11,32 +11,32 @@ Extensions pickup where our core leaves. They help extend the functionality of C Extensions that help improve the user messaging experience. *Recommended for most apps.* -[Pin message](/fundamentals/pin-message)\ [Bitly](/fundamentals/bitly)\ -[Avatars](/fundamentals/avatars)\ -[Message shortcuts](/fundamentals/message-shortcuts)\ [Link Preview](/fundamentals/link-preview)\ +[Message shortcuts](/fundamentals/message-shortcuts)\ +[Pin message](/fundamentals/pin-message)\ [Rich Media Preview](/fundamentals/rich-media-preview)\ [Save message](/fundamentals/save-message)\ [Thumbnail Generation](/fundamentals/thumbnail-generation)\ [TinyURL](/fundamentals/tinyurl)\ -[Voice Transcription](/fundamentals/voice-transcription) +[Voice Transcription](/fundamentals/voice-transcription)\ +[Avatars](/fundamentals/avatars) ### User Engagement Extensions that help increase user engagement. *Recommended for advanced apps.* -[Email replies](/fundamentals/email-replies)\ -[Polls](/fundamentals/polls)\ [Giphy](/fundamentals/giphy)\ -[Mentions](/fundamentals/mentions)\ [Message Translation](/fundamentals/message-translation)\ -[Reactions](/fundamentals/reactions)\ -[Smart Reply](/fundamentals/smart-replies)\ +[Polls](/fundamentals/polls)\ +[Reminders](/fundamentals/reminders)\ [Stickers](/fundamentals/stickers)\ [Stipop](/fundamentals/stickers-stipop)\ [Tenor](/fundamentals/tenor)\ -[Reminders](/fundamentals/reminders)\ +[Email replies](/fundamentals/email-replies)\ +[Mentions](/fundamentals/mentions)\ +[Reactions](/fundamentals/reactions)\ +[Smart Reply](/fundamentals/smart-replies)\ [Live Streaming by api.video](/fundamentals/video-broadcasting) ### Collaboration @@ -46,12 +46,19 @@ Extensions that help with collaboration. *Recommended for advanced apps.* [Collaborative Whiteboard](/fundamentals/collaborative-whiteboard)\ [Collaborative Document](/fundamentals/collaborative-document) +### Security + +*Extensions that help you to build adding extra security to your apps.* *Recommended for live streaming and event apps.* + +[Disappearing messages](/fundamentals/disappearing-messages)\ +[End to End Encryption](/fundamentals/end-to-end-encryption) + ### Customer Support Extensions that help you add support to your app. *Recommended for advanced apps.* -[Intercom](/fundamentals/intercom)\ -[Chatwoot](/fundamentals/chatwoot) +[Chatwoot](/fundamentals/chatwoot)\ +[Intercom](/fundamentals/intercom) ### Notifications @@ -66,10 +73,3 @@ Extensions that help alert users of new messages. *Recommended for all apps.* *Extensions that help you to build a safe messaging environment.* *Recommended for live streaming and event apps.* [Legacy Moderation Extensions](/moderation/legacy-extensions) - -### Security - -*Extensions that help you to build adding extra security to your apps.* *Recommended for live streaming and event apps.* - -[Disappearing messages](/fundamentals/disappearing-messages)\ -[End to End Encryption](/fundamentals/end-to-end-encryption) diff --git a/sdk/javascript/video-view-customisation.mdx b/sdk/javascript/video-view-customisation.mdx index 2fd632577..5e3880224 100644 --- a/sdk/javascript/video-view-customisation.mdx +++ b/sdk/javascript/video-view-customisation.mdx @@ -1,8 +1,16 @@ --- title: "Video View Customisation" +description: "Customize the main video container in CometChat calls — aspect ratio, full screen button, name label, and network label positioning." --- - + +**Quick Reference** +- **Class:** `CometChat.MainVideoContainerSetting` +- **Apply via:** `CallSettingsBuilder.setMainVideoContainerSetting(videoSettings)` +- **Customizable elements:** Aspect ratio, full screen button, name label, network label +- **Position constants:** `POSITION_TOP_LEFT`, `POSITION_TOP_RIGHT`, `POSITION_BOTTOM_LEFT`, `POSITION_BOTTOM_RIGHT` +- **Requires:** [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call) setup + This section will guide you to customise the main video container. @@ -26,16 +34,62 @@ The `MainVideoContainerSetting` Class is the required in case you want to custom Example: - -```typescript + +```javascript let videoSettings = new CometChat.MainVideoContainerSetting(); -videoSettings.setMainVideoAspectRatio(CometChat.CallSettings.ASPECT_RATIO_CONTAIN); +videoSettings.setMainVideoAspectRatio(CometChat.CallSettings.ASPECT_RATIO_CONTAIN); videoSettings.setFullScreenButtonParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); videoSettings.setNameLabelParams(CometChat.CallSettings.POSITION_BOTTOM_LEFT, true, "rgba(27, 27, 27, 0.4)"); -videoSettings.setNetworkLabelParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); +videoSettings.setNetworkLabelParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); ``` - + +```typescript +let videoSettings: CometChat.MainVideoContainerSetting = new CometChat.MainVideoContainerSetting(); +videoSettings.setMainVideoAspectRatio(CometChat.CallSettings.ASPECT_RATIO_CONTAIN); +videoSettings.setFullScreenButtonParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); +videoSettings.setNameLabelParams(CometChat.CallSettings.POSITION_BOTTOM_LEFT, true, "rgba(27, 27, 27, 0.4)"); +videoSettings.setNetworkLabelParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); +``` + + + + + +| Practice | Details | +| --- | --- | +| Aspect ratio choice | Use `ASPECT_RATIO_CONTAIN` to show the full video without cropping; use `ASPECT_RATIO_COVER` for a full-bleed look that may crop edges | +| Label positioning | Avoid placing the name label and network label in the same corner to prevent overlap | +| Full screen button | Keep the full screen button visible for better UX; only hide it if your app provides its own full screen toggle | + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Video settings not applied | `setMainVideoContainerSetting()` not called on `CallSettingsBuilder` | Pass the `MainVideoContainerSetting` object to `CallSettingsBuilder.setMainVideoContainerSetting()` before calling `startCall()` | +| Labels overlapping | Multiple labels positioned in the same corner | Assign different position constants to each label | +| Full screen button missing | Visibility set to `false` | Set the second parameter of `setFullScreenButtonParams()` to `true` | + + + + +## Next Steps + + + + Implement default audio/video calling. + + + Implement direct calling without call events. + + + Add virtual background and blur effects. + + + Record calls for playback. + + diff --git a/sdk/javascript/virtual-background.mdx b/sdk/javascript/virtual-background.mdx index 63edd0a83..0879041c1 100644 --- a/sdk/javascript/virtual-background.mdx +++ b/sdk/javascript/virtual-background.mdx @@ -1,8 +1,16 @@ --- title: "Virtual Background" +description: "Implement virtual background features in CometChat video calls — background blur, custom images, and enforced backgrounds using the JavaScript SDK." --- - + +**Quick Reference** +- **Settings class:** `CometChat.VirtualBackground` +- **Apply via:** `CallSettingsBuilder.setVirtualBackground(virtualBackground)` +- **Toggle UI:** `CallSettingsBuilder.showVirtualBackgroundSetting(true|false)` +- **Runtime control:** `CometChat.CallController.getInstance()` → `setBackgroundBlur()`, `setBackgroundImage()`, `openVirtualBackground()` +- **Requires:** [Default Calling](/sdk/javascript/default-call) or [Direct Calling](/sdk/javascript/direct-call) setup + This section will guide you to implement virtual background feature in video calls. @@ -35,21 +43,17 @@ You can use the `openVirtualBackground()` method to open the virtual background -```js +```javascript let callController = CometChat.CallController.getInstance(); callController.openVirtualBackground(); ``` - - ```typescript let callController: CometChat.CallController = CometChat.CallController.getInstance(); callController.openVirtualBackground(); ``` - - ### Set Background Blur @@ -58,23 +62,19 @@ You can use the `setBackgroundBlur()` method to apply background blur on the vid -```js +```javascript let callController = CometChat.CallController.getInstance(); let blurLevel = 1; callController.setBackgroundBlur(blurLevel); ``` - - ```typescript let callController: CometChat.CallController = CometChat.CallController.getInstance(); let blurLevel: number = 1; callController.setBackgroundBlur(blurLevel); ``` - - ### Set Background Image @@ -83,23 +83,19 @@ You can use the `setBackgroundImage()`method to set the background image. This m -```js +```javascript let callController = CometChat.CallController.getInstance(); let imageURL = "URL_OF_BACKGROUND_IMAGE"; callController.setBackgroundImage(imageURL); ``` - - ```typescript let callController: CometChat.CallController = CometChat.CallController.getInstance(); let imageURL: string = "URL_OF_BACKGROUND_IMAGE"; callController.setBackgroundImage(imageURL); ``` - - ## Virtual Background Settings @@ -114,3 +110,44 @@ The `VirtualBackground` Class is the required in case you want to change how the | `setImages(images: Array)` | This method allows developer to add their custom background image which the end user can choose. | | `enforceBackgroundBlur(enforceBackgroundBlur: number)` | This method starts the call with background blurred. To blur the background you need to pass an integer value between 1-99 which decides the blur level. **Default = 0** | | `enforceBackgroundImage(enforceBackgroundImage: string)` | This methods starts the call with the provided background image. | + + + + +| Practice | Details | +| --- | --- | +| Blur level range | Use values between 1-99 for `enforceBackgroundBlur()`. Higher values produce stronger blur. A value of 0 disables blur | +| Image hosting | Host background images on a CDN for fast loading. Large images may cause lag when applied | +| Enforce vs allow | Use `enforceBackgroundBlur()` or `enforceBackgroundImage()` when you want a mandatory background (e.g., for privacy). Use `allowBackgroundBlur()` and `allowUserImages()` to let users choose | +| Custom buttons | Use `CallController` methods (`setBackgroundBlur`, `setBackgroundImage`, `openVirtualBackground`) when building a custom UI instead of the default CometChat menu | + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Virtual background option not visible | `showVirtualBackgroundSetting(false)` was set | Set `showVirtualBackgroundSetting(true)` in `CallSettingsBuilder` | +| Background blur not applied on call start | `enforceBackgroundBlur()` not set or set to 0 | Pass a value between 1-99 to `enforceBackgroundBlur()` | +| Custom images not appearing | `setImages()` not called or empty array passed | Pass a non-empty array of valid image URLs to `setImages()` | +| `CallController.getInstance()` returns null | Called before the call has started | Only use `CallController` methods after `startCall()` has been invoked | +| User can't upload their own images | `allowUserImages(false)` was set | Set `allowUserImages(true)` in the `VirtualBackground` configuration | + + + + +## Next Steps + + + + Customize the main video container layout. + + + Record calls for playback. + + + Enable screen sharing and presenter mode. + + + Customize the calling UI appearance. + + diff --git a/ui-kit/react/ai-assistant-chat.mdx b/ui-kit/react/ai-assistant-chat.mdx index 2cf33676c..779d91675 100644 --- a/ui-kit/react/ai-assistant-chat.mdx +++ b/ui-kit/react/ai-assistant-chat.mdx @@ -1,7 +1,46 @@ --- title: "AI Assistant Chat" +description: "Build an AI agent chat experience with streaming responses, quick suggestions, chat history, and custom tools using the CometChatAIAssistantChat component." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; + +// Minimal usage — requires a CometChat.User (the AI agent) +const [agent, setAgent] = React.useState(); +React.useEffect(() => { + CometChat.getUser("assistant_uid").then((u) => setAgent(u)); +}, []); + + + +// With common props + +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` + `CometChat.getUser("assistant_uid")` +**Key props:** `user` (CometChat.User, required), `streamingSpeed` (number), `suggestedMessages` (string[]), `hideNewChat` (boolean), `hideChatHistory` (boolean) +**CSS class:** `.cometchat-ai-assistant-chat` +**Events:** none emitted directly + + ## Overview `CometChatAIAssistantChat` is a composite component that assembles the message header, message list, and message composer to provide an AI agent chat experience. It supports streaming responses, quick starter suggestions, "New Chat" to reset context, and a chat history sidebar. @@ -10,9 +49,14 @@ title: "AI Assistant Chat" + + +**Before using this component:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + - -```tsx + +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -33,22 +77,33 @@ export function AIAssistantChatDemo() { ); } - ``` - -```tsx -import { AIAssistantChatDemo } from "./AIAssistantChatDemo"; + +```jsx lines +import React, { useState, useEffect } from "react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; -export default function App() { - return ( -
- -
- ); +export function AIAssistantChatDemo() { + const [agent, setAgent] = useState(null); + + useEffect(() => { + // Replace with your assistant UID + CometChat.getUser("assistant_uid").then((u) => setAgent(u)); + }, []); + + if (!agent) return null; + + return( + <> + + + ); } + ```
@@ -64,13 +119,13 @@ export default function App() { [Actions](/ui-kit/react/components-overview#actions) control how a component behaves. You can hook into the following callbacks: -##### 1. onBackButtonClicked +#### 1. onBackButtonClicked Called when the header back button is clicked (visible when `showBackButton` is true). -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -102,7 +157,7 @@ export function AIAssistantChatDemo() { -```jsx +```jsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -133,13 +188,13 @@ export function AIAssistantChatDemo() { -##### 2. onCloseButtonClicked +#### 2. onCloseButtonClicked Called when the header close button is clicked (visible when `showCloseButton` is true). -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -170,7 +225,7 @@ export function AIAssistantChatDemo() { -```jsx +```jsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -201,13 +256,13 @@ export function AIAssistantChatDemo() { -##### 3. onSendButtonClick +#### 3. onSendButtonClick Called when the composer send button is clicked. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -237,7 +292,7 @@ export function AIAssistantChatDemo() { -```jsx +```jsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -267,13 +322,13 @@ export function AIAssistantChatDemo() { -##### 4. onError +#### 4. onError Listen to errors from the underlying header, list, or composer. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -301,7 +356,7 @@ export function AIAssistantChatDemo() { -```jsx +```jsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -347,7 +402,7 @@ You can set the css of the Assistant Chat Component to customize the styling. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -372,7 +427,7 @@ export function AIAssistantChatDemo = () => { -```jsx +```jsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -396,8 +451,8 @@ export function AIAssistantChatDemo = () => { - -```css + +```css lines .cometchat-ai-assistant-chat .cometchat-ai-assistant-chat__suggested-message-pill { background: #30a46c; @@ -434,7 +489,7 @@ These props tailor the experience. Most message options (copy/edit/delete/react, -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -464,7 +519,7 @@ export function AIAssistantChatDemo = () => { -```jsx +```jsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -536,7 +591,7 @@ Pass an instance of `CometChatAIAssistantTools` to enable tool/function calls du -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -570,7 +625,7 @@ export function AIAssistantChatDemo = () => { -```jsx +```jsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -615,7 +670,7 @@ Provide a custom image for the empty state using `emptyChatImageView`. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -641,7 +696,7 @@ export function AIAssistantChatDemo() { -```jsx +```jsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -677,7 +732,7 @@ Override the empty state greeting message view using the `emptyChatGreetingView` -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -708,7 +763,7 @@ export function AIAssistantChatDemo() { -```jsx +```jsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -738,8 +793,8 @@ export function AIAssistantChatDemo() { - -```css + +```css lines .cometchat-ai-assistant-chat__empty-chat-greeting { display: flex; padding: 8px 20px; @@ -772,7 +827,7 @@ You can override the empty chat intro message view using the `emptyChatIntroMess -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -802,7 +857,7 @@ export function AIAssistantChatDemo() { -```jsx +```jsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAIAssistantChat } from "@cometchat/chat-uikit-react"; @@ -831,8 +886,8 @@ export function AIAssistantChatDemo() { - -```css + +```css lines .cometchat-ai-assistant-chat__empty-chat-intro { display: flex; padding: 12px; @@ -863,7 +918,7 @@ You can set message Templates to AIAssistantChat by using the following code sni -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -898,7 +953,7 @@ export function AIAssistantChatDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -936,3 +991,38 @@ export function AIAssistantChatDemo() { *** + + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows nothing | `user` prop not provided or is `null` | Pass a valid `CometChat.User` object fetched via `CometChat.getUser("assistant_uid")` | +| No streaming response | AI agent not configured in CometChat Dashboard | Set up an AI agent in the Dashboard and use its UID | +| Callback not firing | Wrong prop name or signature | Check the Actions section for exact prop name and parameter types | +| Custom view not appearing | Returning `null` or `undefined` from view prop | Ensure view function returns valid JSX | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Overview of all AI capabilities in the UI Kit + + + Render messages in a conversation + + + Customize message bubble rendering + + + Customize the conversation header + + diff --git a/ui-kit/react/ai-features.mdx b/ui-kit/react/ai-features.mdx index c0f24be3b..e94e3d30c 100644 --- a/ui-kit/react/ai-features.mdx +++ b/ui-kit/react/ai-features.mdx @@ -1,20 +1,27 @@ --- -title: "AI User Copilot" +title: "Smart Chat Features" +description: "Learn about the AI-powered features in CometChat's React UI Kit, including Conversation Starter, Smart Replies, and Conversation Summary." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` + AI features enabled in [CometChat Dashboard](/fundamentals/ai-user-copilot/overview) +- **AI features:** Conversation Starter, Smart Replies, Conversation Summary +- **Key components:** `CometChatMessageList` → [Message List](/ui-kit/react/message-list) (Conversation Starter), `CometChatMessageComposer` → [Message Composer](/ui-kit/react/message-composer) (Smart Replies, Summary), `CometChatAIAssistantChat` → [AI Assistant Chat](/ui-kit/react/ai-assistant-chat) +- **Activation:** Enable each AI feature from the CometChat Dashboard — UI Kit auto-integrates them, no additional code required + + ## Overview CometChat's AI capabilities greatly enhance user interaction and engagement in your application. Let's understand how the React UI Kit achieves these features. - - - +## Smart Chat Features -## Conversation Starters +### Conversation Starter When a user initiates a new chat, the UI kit displays a list of suggested opening lines that users can select, making it easier for them to start a conversation. These suggestions are powered by CometChat's AI, which predicts contextually relevant conversation starters. -For a comprehensive understanding and guide on implementing and using the Conversation Starters, refer to our specific guide on the [Conversation Starter](/fundamentals/ai-user-copilot/conversation-starter). +For a comprehensive understanding and guide on implementing and using the Conversation Starter, refer to our specific guide on the [Conversation Starter](/fundamentals/ai-user-copilot/conversation-starter). Once you have successfully activated the [Conversation Starter](/fundamentals/ai-user-copilot/conversation-starter) from your CometChat Dashboard, the feature will automatically be incorporated into the [MessageList](/ui-kit/react/message-list) Component of UI Kits. @@ -22,7 +29,7 @@ Once you have successfully activated the [Conversation Starter](/fundamentals/ai -## Smart Replies +### Smart Replies Smart Replies are AI-generated responses to messages. They can predict what a user might want to say next by analyzing the context of the conversation. This allows for quicker and more convenient responses, especially on mobile devices. @@ -34,7 +41,7 @@ Once you have successfully activated the [Smart Replies](/fundamentals/ai-user-c -## Conversation Summary +### Conversation Summary The Conversation Summary feature provides concise summaries of long conversations, allowing users to catch up quickly on missed chats. This feature uses natural language processing to determine the main points in a conversation. @@ -45,3 +52,37 @@ Once you have successfully activated the [Conversation Summary](/fundamentals/ai + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| AI features not appearing | Feature not activated in CometChat Dashboard | Enable the specific AI feature from your [Dashboard](/fundamentals/ai-user-copilot/overview) | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but no AI suggestions | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| Conversation Starter not showing | Feature not enabled or no conversation context | Ensure [Conversation Starter](/fundamentals/ai-user-copilot/conversation-starter) is activated in Dashboard | +| Smart Replies not appearing in composer | Feature not enabled in Dashboard | Ensure [Smart Replies](/fundamentals/ai-user-copilot/smart-replies) is activated in Dashboard | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Add an AI-powered assistant to your chat + + + Customize the message list where AI features appear + + + Customize the composer with Smart Replies and Summary + + + Explore core chat features like messaging and reactions + + diff --git a/ui-kit/react/astro-conversation.mdx b/ui-kit/react/astro-conversation.mdx index 605b47376..8fefaaaae 100644 --- a/ui-kit/react/astro-conversation.mdx +++ b/ui-kit/react/astro-conversation.mdx @@ -1,8 +1,18 @@ --- title: "Building a Conversation List + Message View in Astro" sidebarTitle: "Conversation List + Message View" +description: "Build a two-panel conversation list + message view layout in Astro with CometChat React UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Framework:** Astro (with `@astrojs/react` islands) +- **Key component:** `CometChatConversationsWithMessages` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` — use `client:only="react"` directive +- **Parent guide:** [Astro Integration](/ui-kit/react/astro-integration) + + + The Conversation List + Message View layout provides a familiar two‑panel experience, similar to WhatsApp Web or Slack. Users browse conversations on the left and chat in real time on the right. *** @@ -31,7 +41,7 @@ This layout includes: - ```bash + ```bash lines npm create astro@latest cd my-astro-app npm install @@ -239,9 +249,25 @@ This layout includes: - ```bash - npm run dev - ``` + + + ```bash lines + npm run dev + ``` + + + + ```bash lines + pnpm dev + ``` + + + + ```bash lines + yarn dev + ``` + + Open your app and verify you can select conversations on the left and exchange messages on the right. @@ -269,14 +295,61 @@ The sample uses `ensureLogin(uid)` to switch users by logging out if the active *** + +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn’t render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| CSS/theme not applied | Missing CSS import | Add `@import url("@cometchat/chat-uikit-react/css-variables.css");` in your CSS | +| Blank screen after login | Component mounted before init/login completes | Use state to conditionally render after login resolves | +| Messages not loading | Invalid user/group object passed | Ensure you fetch the user/group via SDK before passing to components | + + + + +*** + ## Next Steps -- Customize styles in `src/styles/cometchat-layout.css` -- Add presence or typing indicators -- Explore themes and component overrides in the UI Kit + + + Personalize the chat UI to align with your brand. + + + Explore all available prebuilt UI components. + + + Return to the Astro setup guide. + + + Learn about messaging, real-time updates, and more. + + To build other experiences (One‑to‑One or Tab‑based), reuse `src/lib/cometchat-init.js` and switch the React island component. +--- + +## Next Steps + + + Build a focused single conversation chat experience + + + Create a multi-tab chat interface with navigation + + + Customize the look and feel of your chat UI + + + Explore all available UI Kit components + + diff --git a/ui-kit/react/astro-integration.mdx b/ui-kit/react/astro-integration.mdx index 6ae758a65..b72165883 100644 --- a/ui-kit/react/astro-integration.mdx +++ b/ui-kit/react/astro-integration.mdx @@ -1,8 +1,18 @@ --- title: "Getting Started With CometChat React UI Kit in Astro" sidebarTitle: "Integration" +description: "Step-by-step guide to integrate CometChat React UI Kit into your Astro application using @astrojs/react islands." --- + +- **Package:** `@cometchat/chat-uikit-react` — `npm install @cometchat/chat-uikit-react` + `npx astro add react` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` — must complete before rendering +- **SSR:** CometChat requires browser APIs — use `client:only="react"` directive on Astro islands +- **Init code:** `new UIKitSettingsBuilder().setAppId("APP_ID").setRegion("REGION").setAuthKey("AUTH_KEY").build()` +- **Framework:** Astro (this page) | [React.js](/ui-kit/react/react-js-integration) | [Next.js](/ui-kit/react/next-js-integration) | [React Router](/ui-kit/react/react-router-integration) +- **All components:** [Components Overview](/ui-kit/react/components-overview) + + The CometChat platform lets you add in‑app chat with minimal effort. In Astro, you can integrate CometChat in two primary ways: - Using the CometChat JavaScript SDK directly for framework-agnostic control @@ -88,21 +98,21 @@ The Astro integration relies on the following technologies: - ```bash + ```bash lines npm create astro@latest cd npm install ``` - ```bash + ```bash lines pnpm create astro@latest my-astro-app --template basics cd pnpm install ``` - ```bash + ```bash lines yarn create astro my-astro-app --template basics cd yarn @@ -125,16 +135,16 @@ Choose one of the following: - ```bash + ```bash lines npm i @cometchat/chat-uikit-react ``` - ```bash + ```bash lines npx astro add react ``` After installing, ensure the React integration exists in `astro.config.mjs`: - ```js + ```js lines import { defineConfig } from 'astro/config' import react from '@astrojs/react' @@ -327,17 +337,66 @@ If you need full control, combine the JavaScript SDK with your own UI or mix Ast *** +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| `CometChatUIKit.init()` fails silently | Invalid App ID, Region, or Auth Key | Double-check credentials from the [CometChat Dashboard](https://app.cometchat.com/) | +| Component doesn’t render | `init()` not called or not awaited before rendering | Ensure `init()` completes before mounting components. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| CSS/theme not applied | Missing CSS import | Add `@import url("@cometchat/chat-uikit-react/css-variables.css");` in your global CSS | +| Blank screen after login | Component mounted before init/login completes | Use state to conditionally render after login resolves | +| CometChat components fail on server | Astro SSR tries to render on server | Use `client:only="react"` directive on CometChat islands | +| Auth Key exposed in production | Using Auth Key instead of Auth Token | Switch to [Auth Token](/ui-kit/react/methods#login-using-auth-token) for production | + + + + +*** + ## Next Steps Proceed with your chosen experience: -- Conversation + Messages (UI Kit) in Astro using `CometChatConversationsWithMessages` -- One-to-One/Group Messages (UI Kit) in Astro using `CometChatMessages` -- Tab-Based Chat (UI Kit) in Astro using `CometChatFullScreenView` -- Advanced customizations with themes and components + + + Two-panel layout with conversation list and message view. + + + Focused direct messaging experience without a sidebar. + + + Multi-tab navigation for chats, calls, users, and settings. + + + Customize colors, fonts, and styles to match your branding. + + You’ve set up CometChat in your Astro app. Initialize, log in, and render your preferred chat experience. + +--- + +## Next Steps + + + + Build a two-panel conversation list with message view + + + Create a focused single conversation experience + + + Build a multi-tab chat interface + + + Explore all available UI Kit components + + diff --git a/ui-kit/react/astro-one-to-one-chat.mdx b/ui-kit/react/astro-one-to-one-chat.mdx index 54addcac0..3f02e546f 100644 --- a/ui-kit/react/astro-one-to-one-chat.mdx +++ b/ui-kit/react/astro-one-to-one-chat.mdx @@ -1,8 +1,18 @@ --- title: "Building a One-to-One/Group Chat in Astro" sidebarTitle: "One To One/Group Chat" +description: "Build a focused one-to-one or group chat experience in Astro with CometChat React UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Framework:** Astro (with `@astrojs/react` islands) +- **Key component:** `CometChatMessages` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` — use `client:only="react"` directive +- **Parent guide:** [Astro Integration](/ui-kit/react/astro-integration) + + + The One‑to‑One/Group chat layout focuses on a single conversation, ideal for support chats and private messaging. This guide uses Astro with React islands and the CometChat React UI Kit. *** @@ -211,9 +221,25 @@ The One‑to‑One/Group chat layout focuses on a single conversation, ideal for - ```bash - npm run dev - ``` + + + ```bash lines + npm run dev + ``` + + + + ```bash lines + pnpm dev + ``` + + + + ```bash lines + yarn dev + ``` + + Set `PUBLIC_COMETCHAT_LOGIN_UID` and `PUBLIC_COMETCHAT_TARGET_UID` then verify messages appear for the selected peer. @@ -257,14 +283,61 @@ The island logs out if a different user session is active, then logs in with `PU *** + +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn’t render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| CSS/theme not applied | Missing CSS import | Add `@import url("@cometchat/chat-uikit-react/css-variables.css");` in your CSS | +| Blank screen after login | Component mounted before init/login completes | Use state to conditionally render after login resolves | +| Messages not loading | Invalid user/group object passed | Ensure you fetch the user/group via SDK before passing to components | + + + + +*** + ## Next Steps -- Add typing indicators and read receipts -- Apply theming and component overrides -- Extend to conversations list + messages or tabbed layout + + + Personalize the chat UI to align with your brand. + + + Explore all available prebuilt UI components. + + + Return to the Astro setup guide. + + + Learn about messaging, real-time updates, and more. + + You can reuse `src/lib/cometchat-init.js` across different chat experiences and swap the island component. +--- + +## Next Steps + + + Build a two-panel conversation list with message view + + + Create a multi-tab chat interface with navigation + + + Customize the look and feel of your chat UI + + + Learn about Message List customization options + + diff --git a/ui-kit/react/astro-tab-based-chat.mdx b/ui-kit/react/astro-tab-based-chat.mdx index cf532ef4f..135562802 100644 --- a/ui-kit/react/astro-tab-based-chat.mdx +++ b/ui-kit/react/astro-tab-based-chat.mdx @@ -1,8 +1,18 @@ --- title: "Building a Messaging UI with Tabs, Sidebar, and Message View in Astro" sidebarTitle: "Tab Based Chat Experience" +description: "Build a tab-based messaging UI with chats, calls, users, and groups in Astro with CometChat React UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Framework:** Astro (with `@astrojs/react` islands) +- **Key component:** `CometChatFullScreenView` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` — use `client:only="react"` directive +- **Parent guide:** [Astro Integration](/ui-kit/react/astro-integration) + + + This guide shows how to build a tab‑based messaging UI in Astro using the CometChat React UI Kit. The interface includes sections for Chats, Calls, Users, and Groups with a message panel. *** @@ -325,9 +335,25 @@ Layout structure: - ```bash - npm run dev - ``` + + + ```bash lines + npm run dev + ``` + + + + ```bash lines + pnpm dev + ``` + + + + ```bash lines + yarn dev + ``` + + Log in using `PUBLIC_COMETCHAT_LOGIN_UID`, switch tabs, and open a conversation to send messages. @@ -355,14 +381,43 @@ The message panel shows only for Chats, Users, or Groups. Calls tab does not ope *** + +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn’t render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| CSS/theme not applied | Missing CSS import | Add `@import url("@cometchat/chat-uikit-react/css-variables.css");` in your CSS | +| Blank screen after login | Component mounted before init/login completes | Use state to conditionally render after login resolves | +| Messages not loading | Invalid user/group object passed | Ensure you fetch the user/group via SDK before passing to components | + + + + +*** + ## Next Steps -- Add call handling with CometChat Calls SDK -- Apply theming and component overrides -- Extend with unread badges and notifications + + + Personalize the chat UI to align with your brand. + + + Explore all available prebuilt UI components. + + + Return to the Astro setup guide. + + + Learn about messaging, real-time updates, and more. + + You can reuse `src/lib/cometchat-init.js` and swap the island component to build other experiences. - diff --git a/ui-kit/react/call-buttons.mdx b/ui-kit/react/call-buttons.mdx index 4c67d12bb..0b516d5ef 100644 --- a/ui-kit/react/call-buttons.mdx +++ b/ui-kit/react/call-buttons.mdx @@ -1,7 +1,43 @@ --- title: "Call Buttons" +description: "Add voice and video call buttons to initiate calls using the CometChatCallButtons component." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatCallButtons } from "@cometchat/chat-uikit-react"; + +// For a user + + +// For a group + + +// With options + +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatCallButtons } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` +**Key props:** `user` (CometChat.User), `group` (CometChat.Group), `hideVideoCallButton` (boolean), `hideVoiceCallButton` (boolean), `onError` (callback) +**CSS class:** `.cometchat-call-button` +**Events:** `ccCallRejected`, `ccCallEnded`, `ccOutgoingCall`, `ccMessageSent` + + ## Overview The `Call Button` is a Component provides users with the ability to make calls, access call-related functionalities, and control call settings. Clicking this button typically triggers the call to be placed to the desired recipient. @@ -10,13 +46,18 @@ The `Call Button` is a Component provides users with the ability to make calls, + + +**Before using this component:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + ## Usage ### Integration - -```tsx + +```tsx lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatCallButtons } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -36,36 +77,38 @@ export default CallButtonDemo; - -```tsx -import { CallButtonDemo } from "./CallButtonDemo"; + +```jsx lines +import React, { useState, useEffect } from "react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatCallButtons } from "@cometchat/chat-uikit-react"; -export default function App() { - return ( -
-
- -
-
- ); -} -``` +const CallButtonDemo = () => { + const [chatUser, setChatUser] = useState(null); + useEffect(() => { + CometChat.getUser("uid").then((user) => { + setChatUser(user); + }); + }, []); + return ; +}; +export default CallButtonDemo; +```
-
### Actions [Actions](/ui-kit/react/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs. -##### 1. onError +#### 1. onError This action doesn't change the behavior of the component but rather listens for any errors that occur in the Call Button component. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatCallButtons } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -91,7 +134,7 @@ export default CallButtonDemo; -```js +```js lines import React, { useState, useEffect } from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatCallButtons } from "@cometchat/chat-uikit-react"; @@ -127,7 +170,7 @@ You can set `CallSettingsBuilder` in the Call Buttons Component to customise the -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatCallButtons } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -165,7 +208,7 @@ export default CallButtonDemo; -```js +```js lines import React, { useState, useEffect } from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatCallButtons } from "@cometchat/chat-uikit-react"; @@ -223,7 +266,7 @@ The list of events emitted by the `Call Buttons` component is as follows. -```tsx +```tsx lines const ccCallRejected = CometChatCallEvents.ccCallRejected.subscribe( (call: CometChat.Call) => { //Your Code @@ -255,7 +298,7 @@ const ccMessageSent = CometChatMessageEvents.ccMessageSent.subscribe(() => { -```tsx +```tsx lines ccCallRejected?.unsubscribe(); ccCallEnded?.unsubscribe(); @@ -287,7 +330,7 @@ Using CSS you can customize the look and feel of the component in your app like -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatCallButtons } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -309,7 +352,7 @@ export default CallButtonDemo; -```js +```js lines import React, { useState, useEffect } from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatCallButtons } from "@cometchat/chat-uikit-react"; @@ -331,8 +374,8 @@ export default CallButtonDemo; - -```css + +```css lines .cometchat-call-button { display: flex; width: 183px; @@ -407,3 +450,37 @@ You can customize the properties of the `CometChatOutgoingCall` component by mak You can refer to [CometChatOutgoingCall](/ui-kit/react/outgoing-call) component to know more about each of the above properties. *** + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no buttons | Neither `user` nor `group` prop provided | Pass a valid `CometChat.User` or `CometChat.Group` object | +| Callback not firing | Wrong prop name or signature | Check the Actions section for exact prop name and parameter types | +| Only voice or video button visible | `hideVideoCallButton` or `hideVoiceCallButton` set to `true` | Set the corresponding hide prop to `false` | +| Call fails to initiate | Calls SDK not installed | Install `@cometchat/calls-sdk-javascript`. See [Call Features](/ui-kit/react/call-features) | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Manage outgoing voice and video call UI + + + Handle incoming voice and video calls + + + Display call history and call log details + + + Overview of all calling capabilities + + diff --git a/ui-kit/react/call-features.mdx b/ui-kit/react/call-features.mdx index f9d61886a..97c95009e 100644 --- a/ui-kit/react/call-features.mdx +++ b/ui-kit/react/call-features.mdx @@ -1,11 +1,26 @@ --- title: "Call" +description: "Overview of CometChat's audio and video calling features including incoming calls, outgoing calls, and call logs — with the UI Kit components that power each feature." --- + +- **Packages:** `@cometchat/chat-uikit-react` + `@cometchat/calls-sdk-javascript` (`npm install @cometchat/calls-sdk-javascript`) +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` — Calls SDK must also be installed +- **Call features:** Incoming Call, Outgoing Call, Call Logs, Call Buttons +- **Key components:** `CometChatCallButtons` → [Call Buttons](/ui-kit/react/call-buttons), `CometChatIncomingCall` → [Incoming Call](/ui-kit/react/incoming-call), `CometChatOutgoingCall` → [Outgoing Call](/ui-kit/react/outgoing-call), `CometChatCallLogs` → [Call Logs](/ui-kit/react/call-logs) +- **Auto-detection:** UI Kit automatically detects the Calls SDK and enables call UI components +- **CSS class prefix:** `.cometchat-` + + ## Overview CometChat's Calls feature is an advanced functionality that allows you to seamlessly integrate one-on-one as well as group audio and video calling capabilities into your application. This document provides a technical overview of these features, as implemented in the React UI Kit. + + +**Before using call components:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + ## Integration First, make sure that you've correctly integrated the UI Kit library into your project. If you haven't done this yet or are facing difficulties, refer to our [Getting Started](/ui-kit/react/integration) guide. This guide will walk you through a step-by-step process of integrating our UI Kit into your React project. @@ -14,7 +29,7 @@ Once you've successfully integrated the UI Kit, the next step is to add the Come Add the SDK files to your project's dependencies or libraries: -```java +```bash npm install @cometchat/calls-sdk-javascript ``` @@ -53,3 +68,36 @@ Importantly, the Outgoing Call component is smartly designed to transition autom + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Call buttons not appearing in Message Header | `@cometchat/calls-sdk-javascript` not installed | Run `npm install @cometchat/calls-sdk-javascript` — UI Kit auto-detects it | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| Incoming call screen not showing | `CometChatIncomingCall` not mounted in the component tree | Ensure the component is rendered at the app root level so it can listen for incoming calls | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Add audio and video call buttons to your chat + + + Handle incoming call notifications and UI + + + Display call history and details + + + Explore core chat features like messaging and reactions + + diff --git a/ui-kit/react/call-logs.mdx b/ui-kit/react/call-logs.mdx index 35f786e34..3fd35a67e 100644 --- a/ui-kit/react/call-logs.mdx +++ b/ui-kit/react/call-logs.mdx @@ -1,11 +1,44 @@ --- title: "Call Logs" +description: "Display and manage call history with filtering, custom views, and call-back functionality using the CometChatCallLogs component." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; + +// Minimal usage + + +// With common props + console.log("Selected:", callLog)} + onCallButtonClicked={(callLog) => console.log("Call back:", callLog)} + title="Call History" +/> +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatCallLogs } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` +**Key props:** `onItemClick` (callback), `onCallButtonClicked` (callback), `callLogRequestBuilder` (CallLogRequestBuilder), `title` (string), `activeCall` (object) +**CSS class:** `.cometchat-call-logs` +**Events:** `ccMessageSent` + + ## Overview `CometChatCallLogs` is a Component that shows the list of Call Log available . By default, names are shown for all listed users, along with their avatar if available. + @@ -18,13 +51,18 @@ The `Call Logs` is comprised of the following components: | CometChatListItem | A component that renders data obtained from a Group object on a Tile having a title, subtitle, leading and trailing view. | | CometChatDate | This component used to show the date and time. You can also customize the appearance of this widget by modifying its logic. | + + +**Before using this component:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + ## Usage ### Integration - -```tsx + +```tsx lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -37,36 +75,32 @@ export default CallLogDemo; - -```tsx -import { CallLogDemo } from "./CallLogDemo"; + +```jsx lines +import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; +import React from "react"; -export default function App() { - return ( -
-
- -
-
- ); -} +const CallLogDemo = () => { + return ; +}; + +export default CallLogDemo; ```
-
### Actions [Actions](/ui-kit/react/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs. -##### 1. onItemClick +#### 1. onItemClick `onItemClick` is a callback function which triggers when a call log list item is clicked. It does not have a default behavior. However, you can override its behavior using the following code snippet. -```ts +```ts lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -83,7 +117,7 @@ export default CallLogDemo; -```js +```js lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -101,13 +135,13 @@ export default CallLogDemo; -##### 2. onCallButtonClicked +#### 2. onCallButtonClicked `onCallButtonClicked` is a callback function which triggers when the call button in the trailing view is clicked. -```ts +```ts lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -124,7 +158,7 @@ export default CallLogDemo; -```js +```js lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -142,13 +176,13 @@ export default CallLogDemo; -##### 3. onError +#### 3. onError This is a callback function which is triggered when the component encounters an error. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -166,7 +200,7 @@ export default CallLogDemo; -```js +```js lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -190,7 +224,7 @@ export default CallLogDemo; **Filters** allow you to customize the data displayed in a list within a `Component`. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using `RequestBuilders` of Chat SDK. -##### 1. CallLogRequestBuilder +#### 1. CallLogRequestBuilder The [CallLogRequestBuilder](/sdk/javascript/call-logs) enables you to filter and customize the Call Log based on available parameters in [CallLogRequestBuilder](/sdk/javascript/call-logs). This feature allows you to create more specific and targeted queries when fetching the call logs. The following are the parameters available in [CallLogRequestBuilder](/sdk/javascript/call-logs) @@ -212,7 +246,7 @@ In the example below, we're filtering Call Logs to show only canceled calls and -```ts +```ts lines import { CallLogRequestBuilder } from "@cometchat/calls-sdk-javascript"; import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -234,7 +268,7 @@ export default CallLogDemo; -```js +```js lines import { CallLogRequestBuilder } from "@cometchat/calls-sdk-javascript"; import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -273,7 +307,7 @@ The list of events emitted by the `Call Logs` component is as follows. -```tsx +```tsx lines const ccMessageSent = CometChatMessageEvents.ccMessageSent.subscribe(() => { //Your Code }); @@ -287,7 +321,7 @@ const ccMessageSent = CometChatMessageEvents.ccMessageSent.subscribe(() => { -```tsx +```tsx lines ccMessageSent?.unsubscribe(); ``` @@ -313,7 +347,7 @@ Using CSS you can customize the look and feel of the component in your app like -```ts +```ts lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -327,7 +361,7 @@ export default CallLogDemo; -```js +```js lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -340,8 +374,8 @@ export default CallLogDemo; - -```css + +```css lines .cometchat .cometchat-call-logs .cometchat-list__header-title { background-color: #fce9ea; color: #f76808; @@ -396,7 +430,7 @@ Here is a code snippet demonstrating how you can customize the functionality of -```ts +```ts lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -410,7 +444,7 @@ export default CallLogDemo; -```js +```js lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -466,7 +500,7 @@ The following example demonstrates how to modify the **Call Initiated** timestam -```ts +```ts lines import { CometChatCallLogs, CalendarObject } from "@cometchat/chat-uikit-react"; // Define a custom date format pattern @@ -517,7 +551,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChatCallLogs, CometChatUIKitLoginListener, @@ -591,7 +625,7 @@ export default CallLogDemo; -```js +```js lines import { CometChatCallLogs, CometChatUIKitLoginListener, isMissedCall, isSentByMe, verifyCallUser } from "@cometchat/chat-uikit-react"; const CallLogDemo = () => { @@ -647,8 +681,8 @@ export default CallLogDemo; - -```css + +```css lines .cometchat .cometchat-call-logs .cometchat-list-item__trailing-view { width: auto; overflow: hidden; @@ -711,7 +745,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChatCallLogs, CometChatUIKitLoginListener, @@ -767,7 +801,7 @@ export default CallLogDemo; -```js +```js lines import { CometChatCallLogs,CometChatUIKitLoginListener,isMissedCall,isSentByMe } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -811,8 +845,8 @@ export default CallLogDemo; - -```css + +```css lines .cometchat-call-logs__list-item-subtitle-text { overflow: hidden; color: #727272; @@ -848,7 +882,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CallLog } from "@cometchat/calls-sdk-javascript"; import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -888,7 +922,7 @@ export default CallLogDemo; -```js +```js lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -926,8 +960,8 @@ export default CallLogDemo; - -```css + +```css lines .cometchat .cometchat-call-logs .cometchat-list-item__trailing-view { width: auto; overflow: hidden; @@ -962,7 +996,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CallLog } from "@cometchat/calls-sdk-javascript"; import { CometChatUIKitLoginListener, @@ -995,7 +1029,7 @@ export default CallLogDemo; -```js +```js lines import { CometChatUIKitLoginListener, CometChatCallLogs, @@ -1026,8 +1060,8 @@ export default CallLogDemo; - -```css + +```css lines .call-log-avatar { display: flex; width: 48px; @@ -1085,7 +1119,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CallLog } from "@cometchat/calls-sdk-javascript"; import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -1111,7 +1145,7 @@ export default CallLogDemo; -```js +```js lines import { CometChatCallLogs } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -1135,8 +1169,8 @@ export default CallLogDemo; - -```css + +```css lines .call-log-title { overflow: hidden; color: #141414; @@ -1149,3 +1183,38 @@ export default CallLogDemo; + + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in or no call history exists | Call `CometChatUIKit.login("UID")` after init. Make some test calls first. | +| Callback not firing | Wrong prop name or signature | Check the Actions section for exact prop name and parameter types | +| Custom view not appearing | Returning `null` or `undefined` from view prop | Ensure view function returns valid JSX | +| Filter not working | `CallLogRequestBuilder` missing auth token | Set `.setAuthToken("authtoken")` on the builder | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Add voice and video call buttons to your chat + + + Handle incoming voice and video calls + + + Manage outgoing voice and video calls + + + Build a call log details view + + diff --git a/ui-kit/react/components-overview.mdx b/ui-kit/react/components-overview.mdx index dfc456255..5a0d87305 100644 --- a/ui-kit/react/components-overview.mdx +++ b/ui-kit/react/components-overview.mdx @@ -1,7 +1,52 @@ --- title: "Overview" +description: "Browse all prebuilt UI components in the CometChat React UI Kit — conversations, messages, users, groups, calls, search, and AI." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +All components are imported from `@cometchat/chat-uikit-react`: + +```tsx +import { + CometChatConversations, + CometChatMessageList, + CometChatMessageComposer, + CometChatMessageHeader, + CometChatUsers, + CometChatGroups, + CometChatGroupMembers, + CometChatThreadHeader, + CometChatIncomingCall, + CometChatOutgoingCall, + CometChatCallButtons, + CometChatCallLogs, +} from "@cometchat/chat-uikit-react"; +``` + +- **Chat:** [Conversations](/ui-kit/react/conversations) | [Message List](/ui-kit/react/message-list) | [Message Composer](/ui-kit/react/message-composer) | [Message Header](/ui-kit/react/message-header) +- **Users & Groups:** [Users](/ui-kit/react/users) | [Groups](/ui-kit/react/groups) | [Group Members](/ui-kit/react/group-members) +- **Calls:** [Call Buttons](/ui-kit/react/call-buttons) | [Incoming Call](/ui-kit/react/incoming-call) | [Outgoing Call](/ui-kit/react/outgoing-call) | [Call Logs](/ui-kit/react/call-logs) +- **Other:** [Search](/ui-kit/react/search) | [Thread Header](/ui-kit/react/thread-header) | [AI Assistant Chat](/ui-kit/react/ai-assistant-chat) +- **Customization:** [Message Template](/ui-kit/react/message-template) | [Theming](/ui-kit/react/theme) | [Events](/ui-kit/react/events) + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` before rendering any component +**Component API pattern:** +- Callback actions: `on={(param) => {}}` +- Data filtering: `RequestBuilder={new CometChat.RequestBuilder()}` +- Toggle features: `hide={true|false}` +- Custom rendering: `View={() => JSX}` +- CSS overrides: Target `.cometchat-` class in global CSS +**Calling:** Requires separate `@cometchat/calls-sdk-javascript` package + + CometChat's **UI Kit** is a set of pre-built UI components that allows you to easily craft an in-app chat with all the essential messaging features. ## Actions @@ -27,3 +72,23 @@ All components expose actions to the user, which means that users can interact w Events allow for a decoupled, flexible architecture where different parts of the application can interact without having to directly reference each other. This makes it easier to create complex, interactive experiences, as well as to extend and customize the functionality provided by the CometChat UI Kit. All Components have the ability to emit events. These events are dispatched in response to certain changes or user interactions within the component. By emitting events, these components allow other parts of the application to react to changes or interactions, thus enabling dynamic and interactive behavior within the application. + + +--- + +## Next Steps + + + + Display and manage the list of recent conversations + + + Render messages for a selected conversation + + + Customize colors, fonts, and styles across all components + + + Init, login, logout, and utility methods reference + + diff --git a/ui-kit/react/conversations.mdx b/ui-kit/react/conversations.mdx index a148e2bb6..202168428 100644 --- a/ui-kit/react/conversations.mdx +++ b/ui-kit/react/conversations.mdx @@ -1,24 +1,51 @@ --- title: "Conversations" +description: "Display and manage the list of recent conversations for the logged-in user using the CometChatConversations component in the React UI Kit." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChatConversations } from "@cometchat/chat-uikit-react"; + +// Minimal usage + + +// With common props + setActiveChat(conversation)} + hideReceipts={false} + selectionMode={SelectionMode.none} +/> +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatConversations } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` +**Key props:** `onItemClick: (conversation: CometChat.Conversation) => void`, `conversationsRequestBuilder: CometChat.ConversationsRequestBuilder`, `hideReceipts: boolean`, `selectionMode: SelectionMode`, `activeConversation: CometChat.Conversation` +**CSS class:** `.cometchat-conversations` +**Events:** `CometChatConversationEvents.ccConversationDeleted` + + ## Overview The Conversations is a Component, that shows all conversations related to the currently logged-in user. -This component lists the most recent or latest conversations or contacts with whom you have exchanged messages. It provides a convenient way to quickly access and resume conversations with the people you have been in contact with recently. - - - - ## Usage ### Integration - -```tsx + +```tsx lines import { CometChatConversations, TitleAlignment, @@ -39,23 +66,31 @@ export default ConversationsDemo; - -```tsx -import { ConversationsDemo } from "./ConversationsDemo"; + +```jsx lines +import { + CometChatConversations, +} from "@cometchat/chat-uikit-react"; -export default function App() { +function ConversationsDemo() { return ( -
- +
+
+ +
); } + +export default ConversationsDemo; ``` +**Expected result:** The `CometChatConversations` component renders a scrollable list of recent conversations. Each list item shows: avatar, name, last message preview, timestamp, and unread badge. + ### Actions [Actions](/ui-kit/react/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs. @@ -65,9 +100,10 @@ export default function App() { `OnItemClick` is triggered when you click on a ListItem of the Conversations component. The `OnItemClick` action doesn't have a predefined behavior. You can override this action using the following code snippet. - -```tsx + +```tsx lines import { CometChatConversations } from "@cometchat/chat-uikit-react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; const getOnItemClick = (conversation: CometChat.Conversation) => { console.log("ItemClick:", conversation); @@ -79,6 +115,20 @@ const getOnItemClick = (conversation: CometChat.Conversation) => { + +```jsx lines +import { CometChatConversations } from "@cometchat/chat-uikit-react"; + +const getOnItemClick = (conversation) => { + console.log("ItemClick:", conversation); + // Your custom action here +}; + +; +``` + + + *** @@ -88,12 +138,13 @@ const getOnItemClick = (conversation: CometChat.Conversation) => { The `OnSelect` event is triggered upon the completion of a selection in `SelectionMode`. It does not have a default behavior. However, you can override its behavior using the following code snippet. - -```tsx + +```tsx lines import { CometChatConversations, SelectionMode, } from "@cometchat/chat-uikit-react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; const getOnSelect = ( conversation: CometChat.Conversation, @@ -111,6 +162,26 @@ const getOnSelect = ( + +```jsx lines +import { + CometChatConversations, + SelectionMode, +} from "@cometchat/chat-uikit-react"; + +const getOnSelect = (conversation, selected) => { + console.log("Selected, ", conversation.getConversationId(), selected); + // Your custom action on select +}; + +; +``` + + + *** @@ -120,9 +191,10 @@ const getOnSelect = ( This action doesn't change the behavior of the component but rather listens for any errors that occur in the Conversations component. - -```tsx + +```tsx lines import { CometChatConversations } from "@cometchat/chat-uikit-react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; const handleOnError = (error: CometChat.CometChatException) => { // Your exception handling code @@ -133,6 +205,19 @@ const handleOnError = (error: CometChat.CometChatException) => { + +```jsx lines +import { CometChatConversations } from "@cometchat/chat-uikit-react"; + +const handleOnError = (error) => { + // Your exception handling code +}; + +; +``` + + + *** @@ -142,8 +227,21 @@ const handleOnError = (error: CometChat.CometChatException) => { The `onSearchBarClicked` event is triggered when the user clicks the search bar. It does not have a default behavior. However, you can override its behavior using the following code snippet. - -```tsx + +```tsx lines +import { CometChatConversations } from "@cometchat/chat-uikit-react"; + +const handleSearchClick = () => { + console.log("Search bar clicked"); +}; + +; +``` + + + + +```jsx lines import { CometChatConversations } from "@cometchat/chat-uikit-react"; const handleSearchClick = () => { @@ -173,8 +271,22 @@ You can set filters using the following parameters. 6. **GroupTags:** Filters on specific Group `Tag` - -```tsx + +```tsx lines +import { CometChatConversations } from "@cometchat/chat-uikit-react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; + +; +``` + + + + +```jsx lines import { CometChatConversations } from "@cometchat/chat-uikit-react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; @@ -197,7 +309,7 @@ import { CometChat } from "@cometchat/chat-sdk-javascript"; -```tsxtsx +```tsxtsx lines const ccConversationDeleted = CometChatConversationEvents.ccConversationDeleted.subscribe( (conversation: CometChat.Conversation) => { @@ -210,11 +322,9 @@ const ccConversationDeleted = -*** - -```tsxtsx +```tsxtsx lines ccConversationDeleted?.unsubscribe(); ``` @@ -222,6 +332,8 @@ ccConversationDeleted?.unsubscribe(); +*** + ## Customization To fit your app's design requirements, you can customize the appearance of the conversation component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs. @@ -236,14 +348,14 @@ Using CSS you can customize the look and feel of the component in your app like -```tsx +```tsx lines ``` - -```css + +```css lines .cometchat-conversations .cometchat-list-item__body-title, .cometchat-conversations .cometchat-list__header-title, .cometchat-conversations .cometchat-avatar__text, @@ -284,8 +396,19 @@ Using CSS you can customize the look and feel of the component in your app like These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements. - -```tsx + +```tsx lines +
+
+ +
+
+``` + +
+ + +```jsx lines
@@ -342,7 +465,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatListItem, @@ -373,8 +496,8 @@ const getItemView = (conversation: CometChat.Conversation) => { - -```css + +```css lines .cometchat-conversations .cometchat-avatar { border-radius: 8px; width: 32px; @@ -404,7 +527,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -491,7 +614,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatConversations } from "@cometchat/chat-uikit-react"; @@ -542,8 +665,8 @@ const CustomTrailingButtonView = (conv: CometChat.Conversation) => { - -```css + +```css lines .conversations__trailing-view { display: flex; flex-direction: column; @@ -597,7 +720,7 @@ Assigns the list of text formatters. If the provided list is not null, it sets t -```ts +```ts lines import { CometChatTextFormatter } from "@cometchat/chat-uikit-react"; import DialogHelper from "./Dialog"; import { CometChat } from "@cometchat/chat-sdk-javascript"; @@ -711,7 +834,7 @@ export default ShortcutFormatter; -```tsx +```tsx lines import React from "react"; import ReactDOM from "react-dom"; @@ -778,8 +901,8 @@ export default class DialogHelper { - -```tsx + +```tsx lines import ShortcutFormatter from "./ShortCutFormatter"; ; @@ -803,7 +926,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChatButton, CometChatConversations, @@ -828,8 +951,8 @@ const getHeaderView = () => { - -```css + +```css lines .conversations__header { display: flex; width: 100%; @@ -873,7 +996,7 @@ The `lastMessageDateTimeFormat` property allows you to customize the **Last Mess Default Date Time Format: -```ruby +```ruby lines new CalendarObject({ today: `hh:mm A`, // Example: "10:30 AM" yesterday: `[yesterday]`, // Example: "yesterday" @@ -885,7 +1008,7 @@ The following example demonstrates how to modify the **Last Message** timestamp -```ts +```ts lines import { CometChatConversations, CalendarObject, @@ -931,7 +1054,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatConversations } from "@cometchat/chat-uikit-react"; @@ -963,8 +1086,8 @@ const customTitleView = (conversation: CometChat.Conversation) => { - -```css + +```css lines .cometchat-conversations .conversations__title-view { display: flex; gap: 4px; @@ -1013,7 +1136,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatConversations } from "@cometchat/chat-uikit-react"; @@ -1051,8 +1174,8 @@ function getFormattedTimestamp(timestamp: number): string { - -```css + +```css lines .cometchat-conversations .cometchat-list-item__body-subtitle { overflow: hidden; color: var(--cometchat-text-color-secondary, #727272); @@ -1090,7 +1213,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChatOption, CometChatConversations, @@ -1135,8 +1258,8 @@ const getOptions = (conversation: CometChat.Conversation) => { - -```css + +```css lines .cometchat-conversations .cometchat-menu-list__main-menu-item-icon-delete { background: red; } @@ -1156,7 +1279,7 @@ const getOptions = (conversation: CometChat.Conversation) => { -##### Structure of CometChatOption +#### Structure of CometChatOption | Name | Description | | ----------- | ----------------------------------------------------- | @@ -1166,3 +1289,49 @@ const getOptions = (conversation: CometChat.Conversation) => { | **onClick** | Method to be invoked when user clicks on each option. | *** + + +## Component API Pattern + +| Customization Type | Prop Pattern | Example | +| --- | --- | --- | +| Callback actions | `on={(param) => {}}` | `onItemClick={(conversation) => {}}` | +| Data filtering | `conversationsRequestBuilder={builder}` | `conversationsRequestBuilder={new CometChat.ConversationsRequestBuilder().setLimit(10)}` | +| Toggle features | `hide={true\|false}` | `hideReceipts={true}` | +| Custom rendering | `View={() => JSX}` | `itemView={(conversation) =>
...
}` | +| CSS overrides | Target `.cometchat-conversations` class in global CSS | `.cometchat-conversations .cometchat-list-item { ... }` | + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| `onItemClick` not firing | Wrong prop name or missing callback | Use `onItemClick` (not `onClick` or `onPress`) | +| Custom view not appearing | Returning `null` or `undefined` from view prop | Ensure view function returns valid JSX | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | +| Conversations list empty after login | `ConversationsRequestBuilder` filters too restrictive | Remove or adjust the `conversationsRequestBuilder` prop | +| Events not received | Listener not subscribed or unsubscribed too early | Subscribe in `useEffect` and unsubscribe in cleanup | + + + + +--- + +## Next Steps + + + + Display messages for the selected conversation + + + Browse and select users to start new conversations + + + Browse and manage group conversations + + + Customize the appearance of the conversations list + + diff --git a/ui-kit/react/core-features.mdx b/ui-kit/react/core-features.mdx index 78a6de7de..61dcf4684 100644 --- a/ui-kit/react/core-features.mdx +++ b/ui-kit/react/core-features.mdx @@ -1,13 +1,29 @@ --- title: "Core" +description: "Overview of CometChat's core chat features including instant messaging, media sharing, read receipts, typing indicators, user presence, reactions, mentions, threaded conversations, search, and moderation — with the UI Kit components that power each feature." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` — must complete before rendering any component +- **Core features:** Instant Messaging, Media Sharing, Read Receipts, Mark as Unread, Typing Indicator, User Presence, Reactions, Mentions, Quoted Reply, Search, Threaded Conversations, Moderation, Report Message, Group Chat +- **Key components:** `CometChatConversations` → [Conversations](/ui-kit/react/conversations), `CometChatMessageList` → [Message List](/ui-kit/react/message-list), `CometChatMessageComposer` → [Message Composer](/ui-kit/react/message-composer), `CometChatMessageHeader` → [Message Header](/ui-kit/react/message-header), `CometChatUsers` → [Users](/ui-kit/react/users), `CometChatGroups` → [Groups](/ui-kit/react/groups), `CometChatGroupMembers` → [Group Members](/ui-kit/react/group-members) +- **CSS class prefix:** `.cometchat-` +- **Theming:** Override CSS variables on `.cometchat` class. See [Theming](/ui-kit/react/theme) + + ## Overview The UI Kit comprises a variety of components, each designed to work seamlessly with one another to deliver a comprehensive and intuitive chat experience. + Here's how different UI Kit components work together to achieve CometChat's Core features: + + +**Before using these components:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + ## Instant Messaging At the heart of CometChat's functionality is the ability to support real-time text messaging. Users can send and receive instant messages, fostering quick and efficient communication. @@ -115,45 +131,40 @@ Mentions is a robust feature provided by CometChat that enhances the interactivi | [Message Composer](/ui-kit/react/message-composer) | [Message Composer](/ui-kit/react/message-composer) is a component that allows users to craft and send various types of messages, including the usage of the mentions feature for direct addressing within the conversation. | | [Message List](/ui-kit/react/message-list) | [Message List](/ui-kit/react/message-list) is a component that displays a list of sent and received messages. It also supports the rendering of Mentions, enhancing the readability and interactivity of conversations. | -## Quoted Reply +## Threaded Conversations -Quoted Reply is a robust feature provided by CometChat that enables users to quickly reply to specific messages by selecting the "Reply" option from a message's action menu. This enhances context, keeps conversations organized, and improves overall chat experience in both 1-1 and group chats. +The Threaded Conversations feature enables users to respond directly to a specific message in a chat. This keeps conversations organized and enhances the user experience by maintaining context, especially in group chats. - + -| Components | Functionality | -| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [Message List](/ui-kit/react/message-list) | [Message List](/ui-kit/react/message-list) supports replying to messages via the "Reply" option. Users can select "Reply" on a message to open the composer with the quoted reply pre-filled, maintaining context. | -| [Message Composer](/ui-kit/react/message-composer) | [Message Composer](/ui-kit/react/message-composer) works seamlessly with Quoted Message by showing the quoted reply above the input field, letting users compose their response in proper context. | +| Components | Functionality | +| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | +| [Threaded Message Preview](/ui-kit/react/threaded-message-preview) | [Threaded Message Preview](/ui-kit/react/threaded-message-preview) component displays the parent message along with the number of replies. | -## Conversation and Advanced Search +## Quoted Replies -Conversation and Advanced Search is a powerful feature provided by CometChat that enables users to quickly find conversations, messages, and media across chats in real time. It supports filters, scopes, and custom actions, allowing users to locate content efficiently while keeping the chat experience smooth and intuitive. +Quoted Replies is a robust feature provided by CometChat that enables users to quickly reply to specific messages by selecting the "Reply" option from a message's action menu. This enhances context, keeps conversations organized, and improves overall chat experience in both 1-1 and group chats. - + | Components | Functionality | | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [Search](/ui-kit/react/search) | [Search](/ui-kit/react/search) allows users to search across conversations and messages in real time. Users can click on a result to open the conversation or jump directly to a specific message. | -| [Message Header](/ui-kit/react/message-header) | [Message Header](/ui-kit/react/message-header) shows the search button in the chat header, allowing users to search within a conversation. | -| [Message List](/ui-kit/react/message-list) | [Message List](/ui-kit/react/message-list) shows the selected message when clicked from search results and highlights it in the message list. | -| [Conversations](/ui-kit/react/conversations) | [Conversations](/ui-kit/react/conversations) displays the search input. | +| [Message List](/ui-kit/react/message-list) | [Message List](/ui-kit/react/message-list) supports replying to messages via the "Reply" option. Users can select "Reply" on a message to open the composer with the quoted reply pre-filled, maintaining context. | +| [Message Composer](/ui-kit/react/message-composer) | [Message Composer](/ui-kit/react/message-composer) works seamlessly with Quoted Message by showing the quoted reply above the input field, letting users compose their response in proper context. | -## Threaded Conversations +## Group Chat -The Threaded Conversations feature enables users to respond directly to a specific message in a chat. This keeps conversations organized and enhances the user experience by maintaining context, especially in group chats. +CometChat facilitates Group Chats, allowing users to have conversations with multiple participants simultaneously. This feature is crucial for team collaborations, group discussions, social communities, and more. - + -| Components | Functionality | -| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | -| [Threaded Message Preview](/ui-kit/react/threaded-message-preview) | [Threaded Message Preview](/ui-kit/react/threaded-message-preview) component displays the parent message along with the number of replies. | +For a comprehensive understanding and guide on implementing and using the Groups feature in CometChat, you should refer to our detailed guide on [Groups](/ui-kit/react/groups). ## Moderation @@ -189,12 +200,52 @@ Learn more about how flagged messages are handled, reviewed, and moderated in th | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [Message List](/ui-kit/react/message-list) | [Message List](/ui-kit/react/message-list) provides the "Report Message" option in the message actions menu, allowing users to initiate the reporting process for inappropriate messages. | -## Group Chat +## Conversation and Advanced Search -CometChat facilitates Group Chats, allowing users to have conversations with multiple participants simultaneously. This feature is crucial for team collaborations, group discussions, social communities, and more. +Conversation and Advanced Search is a powerful feature provided by CometChat that enables users to quickly find conversations, messages, and media across chats in real time. It supports filters, scopes, and custom actions, allowing users to locate content efficiently while keeping the chat experience smooth and intuitive. - + +| Components | Functionality | +| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [Search](/ui-kit/react/search) | [Search](/ui-kit/react/search) allows users to search across conversations and messages in real time. Users can click on a result to open the conversation or jump directly to a specific message. | +| [Message Header](/ui-kit/react/message-header) | [Message Header](/ui-kit/react/message-header) shows the search button in the chat header, allowing users to search within a conversation. | +| [Message List](/ui-kit/react/message-list) | [Message List](/ui-kit/react/message-list) shows the selected message when clicked from search results and highlights it in the message list. | +| [Conversations](/ui-kit/react/conversations) | [Conversations](/ui-kit/react/conversations) displays the search input. | + For a comprehensive understanding and guide on implementing and using the Groups feature in CometChat, you should refer to our detailed guide on [Groups](/ui-kit/react/groups). + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| Callback not firing | Wrong prop name or signature | Check the Actions section on the component page for exact prop name and parameter types | +| Custom view not appearing | Returning `null` or `undefined` from view prop | Ensure view function returns valid JSX | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Browse all available UI Kit components + + + Customize the look and feel of your chat UI + + + Add audio and video calling to your app + + + Explore AI-powered chat capabilities + + diff --git a/ui-kit/react/custom-text-formatter-guide.mdx b/ui-kit/react/custom-text-formatter-guide.mdx index eadbdc933..c8487faf3 100644 --- a/ui-kit/react/custom-text-formatter-guide.mdx +++ b/ui-kit/react/custom-text-formatter-guide.mdx @@ -1,7 +1,19 @@ --- title: "Custom Text Formatter" +description: "Extend the CometChatTextFormatter base class to implement custom inline text patterns with regex and callbacks." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Key class:** `CometChatTextFormatter` (abstract base class for custom formatters) +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Purpose:** Extend to create custom inline text patterns with regex, styling, and callbacks +- **Features:** Text formatting, customizable styles, dynamic text replacement, input field integration, key event callbacks +- **Sample app:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) +- **Related:** [ShortCut Formatter](/ui-kit/react/shortcut-formatter-guide) | [Mentions Formatter](/ui-kit/react/mentions-formatter-guide) | [All Guides](/ui-kit/react/guide-overview) + + + ## Overview You can create your custom text formatter for CometChat using the `CometChatTextFormatter`. `CometChatTextFormatter` is an abstract utility class that serves as a foundational structure for enabling text formatting in the message composer and text message bubbles. It can be extended to create custom formatter classes, tailored to suit specific application needs, making it a valuable tool for text customization and enhancement in chat interfaces. @@ -73,7 +85,7 @@ Below is an example demonstrating how to use a custom formatter class in compone -```ts +```ts lines import { CometChatTextFormatter } from "@cometchat/chat-uikit-react"; class HashTagTextFormatter extends CometChatTextFormatter { @@ -227,7 +239,7 @@ export default HashTagTextFormatter; -```tsx +```tsx lines import { HashTagTextFormatter } from "./HashTagTextFormatter"; export default function MessageListDemo() { @@ -288,7 +300,7 @@ Upon calling `reRender`, the composer will invoke the `getFormattedText` functio -```js +```js lines /** * If the input text is provided, it returns the formatted text. Otherwise, it edits the text using the current cursor position. * @param {string|null} inputText - The text to format. @@ -306,7 +318,7 @@ Upon calling `reRender`, the composer will invoke the `getFormattedText` functio -```js +```js lines /** * Handles 'keydown' events. * @param {KeyboardEvent} event - The keyboard event. @@ -325,7 +337,7 @@ onKeyUp(event: KeyboardEvent) { -```js +```js lines /** * Handles 'keydown' events. * @param {KeyboardEvent} event - The keyboard event. @@ -336,7 +348,7 @@ onKeyDown(event: KeyboardEvent) {} -```js +```js lines /** * Composer and Text Bubbles will call this function when rendering the HTML content. * This will be called for each HTML Element present in the formatted string. @@ -407,7 +419,7 @@ registerEventListeners(element: HTMLElement, domTokenList: DOMTokenList) { -```js +```js lines /** * Returns the original unformatted text from the input text. * @param {string|null|undefined} inputText - The input text to get original text from. @@ -433,4 +445,23 @@ registerEventListeners(element: HTMLElement, domTokenList: DOMTokenList) { - \ No newline at end of file + + +## Next Steps + + + + Add @mentions with styled tokens. + + + Customize the message input component. + + + Browse all feature and formatter guides. + + + Full working sample application on GitHub. + + + +*** diff --git a/ui-kit/react/events.mdx b/ui-kit/react/events.mdx index 0ba3e00fc..7ec01ddcb 100644 --- a/ui-kit/react/events.mdx +++ b/ui-kit/react/events.mdx @@ -1,7 +1,15 @@ --- title: "Events" +description: "Reference for CometChat React UI Kit events including conversation, user, group, message, and call events." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Event categories:** `CometChatConversationEvents` (deleted, updated), `CometChatUserEvents` (blocked/unblocked), `CometChatGroupEvents` (created, deleted, member changes), `CometChatMessageEvents` (sent, edited, replied), `CometChatCallEvents` (outgoing, accepted, rejected, ended) +- **UI events:** Active chat changed +- **Purpose:** Decoupled communication between UI Kit components — subscribe to events to react to changes without direct component references + + ## Overview Events allow for a decoupled, flexible architecture where different parts of the application can interact without having to directly reference each other. This makes it easier to create complex, interactive experiences, as well as to extend and customize the functionality provided by the CometChat UI Kit. @@ -14,8 +22,8 @@ All components have the ability to emit events. These events are dispatched in r | Name | Description | | ------------------------- | ------------------------------------------------------------------------------------------------ | -| ccConversationDeleted | This event is triggered when the user successfully deletes a conversation. | -| ccUpdateConversation | This event is triggered to update a conversation in the conversation list. Takes a Conversation object to update. | +| **ccConversationDeleted** | This event is triggered when the user successfully deletes a conversation. | +| **ccUpdateConversation** | This event is triggered to update a conversation in the conversation list. Takes a Conversation object to update. | ### CometChatUserEvents @@ -25,8 +33,8 @@ It consists of the following events: | Name | Description | | --------------- | ------------------------------------------------------------------------- | -| ccUserBlocked | This event is triggered when the user successfully blocks another user. | -| ccUserUnblocked | This event is triggered when the user successfully unblocks another user. | +| **ccUserBlocked** | This event is triggered when the user successfully blocks another user. | +| **ccUserUnblocked** | This event is triggered when the user successfully unblocks another user. | ### CometChatGroupEvents @@ -36,16 +44,16 @@ It consists of the following events: | Name | Description | | ------------------------- | ------------------------------------------------------------------------------------ | -| ccGroupCreated | This event is triggered when the user creates a group successfully | -| ccGroupDeleted | This event is triggered when the group member deletes the group successfully | -| ccGroupLeft | This event is triggered when the group member leaves the group successfully | -| ccGroupMemberScopeChanged | This event is triggered when the group member's scope is updated successfully | -| ccGroupMemberKicked | This event is triggered when the group member is kicked | -| ccGroupMemberBanned | This event is triggered when the group member is banned | -| ccGroupMemberUnbanned | This event is triggered when the group member is un-banned | -| ccGroupMemberJoined | This event is triggered when a user joins the group | -| ccGroupMemberAdded | This event is triggered when a user is added to the group | -| ccOwnershipChanged | This event is triggered when the group ownership is assigned to another group member | +| **ccGroupCreated** | This event is triggered when the user creates a group successfully | +| **ccGroupDeleted** | This event is triggered when the group member deletes the group successfully | +| **ccGroupLeft** | This event is triggered when the group member leaves the group successfully | +| **ccGroupMemberScopeChanged** | This event is triggered when the group member's scope is updated successfully | +| **ccGroupMemberKicked** | This event is triggered when the group member is kicked | +| **ccGroupMemberBanned** | This event is triggered when the group member is banned | +| **ccGroupMemberUnbanned** | This event is triggered when the group member is un-banned | +| **ccGroupMemberJoined** | This event is triggered when a user joins the group | +| **ccGroupMemberAdded** | This event is triggered when a user is added to the group | +| **ccOwnershipChanged** | This event is triggered when the group ownership is assigned to another group member | ### CometChatMessageEvents @@ -55,22 +63,22 @@ It consists of the following events: | Name | Description | | -------------------------- | --------------------------------------------------------------------------------------------------------- | -| ccMessageSent | This event is triggered when the sent message is in transit and also when it is received by the receiver. | -| ccMessageEdited | This event is triggered when the user successfully edits the message. | -| ccReplyToMessage | This event is triggered when the user successfully replies to a message. | -| ccMessageDeleted | This event is triggered when the user successfully deletes the message. | -| ccMessageRead | This event is triggered when the sent message is read by the receiver. | -| ccLiveReaction | This event is triggered when the user sends a live reaction. | -| onTextMessageReceived | This event is emitted when the CometChat SDK listener emits a text message. | -| onMediaMessageReceived | This event is emitted when the CometChat SDK listener emits a media message. | -| onCustomMessageReceived | This event is emitted when the CometChat SDK listener emits a custom message. | -| onTypingStarted | This event is emitted when the CometChat SDK listener indicates that a user has started typing. | -| onTypingEnded | This event is emitted when the CometChat SDK listener indicates that a user has stopped typing. | -| onMessagesDelivered | This event is emitted when the CometChat SDK listener indicates that messages have been delivered. | -| onMessagesRead | This event is emitted when the CometChat SDK listener indicates that messages have been read. | -| onMessageEdited | This event is emitted when the CometChat SDK listener indicates that a message has been edited. | -| onMessageDeleted | This event is emitted when the CometChat SDK listener indicates that a message has been deleted. | -| onTransientMessageReceived | This event is emitted when the CometChat SDK listener emits a transient message. | +| **ccMessageSent** | This event is triggered when the sent message is in transit and also when it is received by the receiver. | +| **ccMessageEdited** | This event is triggered when the user successfully edits the message. | +| **ccReplyToMessage** | This event is triggered when the user successfully replies to a message. | +| **ccMessageDeleted** | This event is triggered when the user successfully deletes the message. | +| **ccMessageRead** | This event is triggered when the sent message is read by the receiver. | +| **ccLiveReaction** | This event is triggered when the user sends a live reaction. | +| **onTextMessageReceived** | This event is emitted when the CometChat SDK listener emits a text message. | +| **onMediaMessageReceived** | This event is emitted when the CometChat SDK listener emits a media message. | +| **onCustomMessageReceived** | This event is emitted when the CometChat SDK listener emits a custom message. | +| **onTypingStarted** | This event is emitted when the CometChat SDK listener indicates that a user has started typing. | +| **onTypingEnded** | This event is emitted when the CometChat SDK listener indicates that a user has stopped typing. | +| **onMessagesDelivered** | This event is emitted when the CometChat SDK listener indicates that messages have been delivered. | +| **onMessagesRead** | This event is emitted when the CometChat SDK listener indicates that messages have been read. | +| **onMessageEdited** | This event is emitted when the CometChat SDK listener indicates that a message has been edited. | +| **onMessageDeleted** | This event is emitted when the CometChat SDK listener indicates that a message has been deleted. | +| **onTransientMessageReceived** | This event is emitted when the CometChat SDK listener emits a transient message. | ### CometChatCallEvents @@ -80,10 +88,10 @@ It consists of the following events: | Name | Description | | -------------- | ---------------------------------------------------------------------------- | -| ccOutgoingCall | This event is triggered when the user initiates a voice/video call. | -| ccCallAccepted | This event is triggered when the initiated call is accepted by the receiver. | -| ccCallRejected | This event is triggered when the initiated call is rejected by the receiver. | -| ccCallEnded | This event is triggered when the initiated call successfully ends. | +| **ccOutgoingCall** | This event is triggered when the user initiates a voice/video call. | +| **ccCallAccepted** | This event is triggered when the initiated call is accepted by the receiver. | +| **ccCallRejected** | This event is triggered when the initiated call is rejected by the receiver. | +| **ccCallEnded** | This event is triggered when the initiated call successfully ends. | ### UI events @@ -93,4 +101,41 @@ It consists of the following events: | Name | Description | | ------------------- | ---------------------------------------------------------------------------- | -| ccActiveChatChanged | This event is triggered when the user navigates to a particular chat window. | +| **ccActiveChatChanged** | This event is triggered when the user navigates to a particular chat window. | + +*** + +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Event listener not firing | Subscribed to wrong event name | Check the event tables above for exact event names | +| Duplicate event triggers | Multiple subscriptions without cleanup | Unsubscribe in `useEffect` cleanup or component unmount | +| Event fires but UI doesn’t update | State not updated in event handler | Ensure you call `setState` or equivalent in the handler | + + + + +*** + +## Next Steps + + + + Init, login, logout, and message-sending methods. + + + Explore all available prebuilt UI components. + + + Display and manage conversation lists. + + + Render real-time message threads. + + + +*** diff --git a/ui-kit/react/extensions.mdx b/ui-kit/react/extensions.mdx index 15f4332d9..83c1c7d64 100644 --- a/ui-kit/react/extensions.mdx +++ b/ui-kit/react/extensions.mdx @@ -1,32 +1,102 @@ --- title: "Extensions" +description: "Overview of CometChat's extensions grouped by Dashboard categories (User Experience, User Engagement, Collaboration, Security, Customer Support, Smart Chat Features) and how they auto-integrate into React UI Kit components." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` + Extensions enabled in [CometChat Dashboard](/fundamentals/extensions-overview) +- **Extension categories:** User Experience, User Engagement, Collaboration, Security, Customer Support, Smart Chat Features +- **Key components:** `CometChatMessageComposer` → [Message Composer](/ui-kit/react/message-composer) (Stickers, Polls, Whiteboard, Document), `CometChatMessageList` → [Message List](/ui-kit/react/message-list) (Translation, Link Preview, Thumbnails) +- **Activation:** Enable each extension from the CometChat Dashboard — UI Kit auto-integrates them, no additional code required + + ## Overview CometChat's UI Kit offers built-in support for various extensions, enriching the chatting experience with enhanced functionality. These extensions augment your chat application, making it more interactive, secure, and efficient. + + +**Before using extensions:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. Extensions must also be activated from the [CometChat Dashboard](/fundamentals/extensions-overview). + + Activating extensions within CometChat is a straightforward process through your application's dashboard. For detailed instructions, refer to our guide on [Extensions](/fundamentals/extensions-overview). Once you've enabled your desired extension in the dashboard, it seamlessly integrates into your CometChat application upon initialization and successful login. It's important to note that extension features will only be available if they are supported by the CometChat UI Kit. -CometChat's UI Kit provides native support for 12 powerful extensions. This effortless integration enables you to enhance your chat application with engaging features without any additional coding. Simply enable the desired extensions from the CometChat Dashboard, and they will automatically enhance the relevant components of your application, providing a richer and more engaging experience for your users. +CometChat's UI Kit provides native support for a wide range of powerful extensions. This effortless integration enables you to enhance your chat application with engaging features without any additional coding. Simply enable the desired extensions from the CometChat Dashboard, and they will automatically enhance the relevant components of your application, providing a richer and more engaging experience for your users. ## Built-in Extensions -Here's a guide on how you can enable and integrate these extensions: +Here's a guide on how you can enable and integrate these extensions. The grouping below mirrors the CometChat Dashboard. -### Stickers +### User Experience -The Stickers extension allows users to express their emotions more creatively. It adds a much-needed fun element to the chat by allowing users to send various pre-designed stickers. For a comprehensive understanding and guide on implementing and using the Sticker Extension, refer to our specific guide on the [Sticker Extension](/fundamentals/stickers). +#### Bitly -Once you have successfully activated the [Sticker Extension](/fundamentals/stickers) from your CometChat Dashboard, the feature will automatically be incorporated into the [Message Composer](/ui-kit/react/message-composer) component of UI Kits. +The Bitly extension allows you to shorten long URLs in your text messages using Bitly's URL shortening service. For a comprehensive understanding and guide on implementing and using the Bitly Extension, refer to our specific guide on the [Bitly Extension](/fundamentals/bitly). + +#### Link Preview + +The Link Preview extension provides a summary of the URL shared in the chat. It includes the title, a description, and a thumbnail image from the web page. For a comprehensive understanding and guide on implementing and using the Link Preview Extension, refer to our specific guide on the [Link Preview Extension](/fundamentals/link-preview). + +Once you have successfully activated the [Link Preview Extension](/fundamentals/link-preview) from your CometChat Dashboard, the feature will automatically be incorporated into the Message Bubble of [MessageList Component](/ui-kit/react/message-list) component of UI Kits. - + + + +#### Message Shortcuts + +The Message Shortcuts extension enables users to send predefined messages using short codes. For example, typing `!hb` can automatically expand to `Happy birthday!`. For a comprehensive understanding and guide on implementing and using the Message Shortcuts Extension, refer to our specific guide on the [Message Shortcuts Extension](/fundamentals/message-shortcuts). + +#### Pin Message + +The Pin Message extension allows users to pin important messages in a conversation, making them easily accessible for all participants. For a comprehensive understanding and guide on implementing and using the Pin Message Extension, refer to our specific guide on the [Pin Message Extension](/fundamentals/pin-message). + +#### Rich Media Preview + +The Rich Media Preview extension generates rich preview panels for URLs shared in messages, fetching detailed information from popular sites using iFramely. For a comprehensive understanding and guide on implementing and using the Rich Media Preview Extension, refer to our specific guide on the [Rich Media Preview Extension](/fundamentals/rich-media-preview). + +#### Save Message + +The Save Message extension allows users to bookmark messages for later reference. Saved messages are private and visible only to the user who saved them. For a comprehensive understanding and guide on implementing and using the Save Message Extension, refer to our specific guide on the [Save Message Extension](/fundamentals/save-message). + +#### Thumbnail Generation + +The Thumbnail Generation extension automatically creates a smaller preview image whenever a larger image is shared, helping to reduce the upload/download time and bandwidth usage. For a comprehensive understanding and guide on implementing and using the Thumbnail Generation Extension, refer to our specific guide on the [Thumbnail Generation Extension](/fundamentals/thumbnail-generation). + +Once you have successfully activated the [Thumbnail Generation Extension](/fundamentals/thumbnail-generation) from your CometChat Dashboard, the feature will automatically be incorporated into the Message Bubble of [MessageList Component](/ui-kit/react/message-list) component of UI Kits. + + + + + +#### TinyURL + +The TinyURL extension provides URL shortening capabilities for messages, similar to Bitly but using the TinyURL service. For a comprehensive understanding and guide on implementing and using the TinyURL Extension, refer to our specific guide on the [TinyURL Extension](/fundamentals/tinyurl). + +#### Voice Transcription + +The Voice Transcription extension converts audio messages into text, making it easier to read voice messages without playing them. For a comprehensive understanding and guide on implementing and using the Voice Transcription Extension, refer to our specific guide on the [Voice Transcription Extension](/fundamentals/voice-transcription). + +### User Engagement + +#### Giphy + +The Giphy extension allows users to search for and share GIFs in their conversations, adding a fun and expressive element to chats. For a comprehensive understanding and guide on implementing and using the Giphy Extension, refer to our specific guide on the [Giphy Extension](/fundamentals/giphy). + +#### Message Translation + +The Message Translation extension in CometChat is designed to translate any message into your local locale. It eliminates language barriers, making the chat more inclusive. For a comprehensive understanding and guide on implementing and using the Message Translation Extension, refer to our specific guide on the [Message Translation Extension](/fundamentals/message-translation). + +Once you have successfully activated the [Message Translation Extension](/fundamentals/message-translation) from your CometChat Dashboard, the feature will automatically be incorporated into the Action Sheet of [MessageList Component](/ui-kit/react/message-list) component of UI Kits. + + + -### Polls +#### Polls The Polls extension enhances group discussions by allowing users to create polls. Users can ask questions with a predefined list of answers, enabling a quick, organized way to gather group opinions. For a comprehensive understanding and guide on implementing and using the Polls Extension, refer to our specific guide on the [Polls Extension](/fundamentals/polls). @@ -36,17 +106,31 @@ Once you have successfully activated the [Polls Extension](/fundamentals/polls) -### Collaborative Whiteboard +#### Reminders -The Collaborative Whiteboard extension facilitates real-time collaboration. Users can draw, brainstorm, and share ideas on a shared digital whiteboard. For a comprehensive understanding and guide on implementing and using the Collaborative Whiteboard Extension, refer to our specific guide on the [Collaborative Whiteboard Extension](/fundamentals/collaborative-whiteboard). +The Reminders extension allows users to set reminders for messages or create personal reminders. When a reminder is due, a bot sends a notification message to the user. For a comprehensive understanding and guide on implementing and using the Reminders Extension, refer to our specific guide on the [Reminders Extension](/fundamentals/reminders). -Once you have successfully activated the [Collaborative Whiteboard Extension](/fundamentals/collaborative-whiteboard) from your CometChat Dashboard, the feature will automatically be incorporated into the Action Sheet of the [Message Composer](/ui-kit/react/message-composer) component of UI Kits. +#### Stickers + +The Stickers extension allows users to express their emotions more creatively. It adds a much-needed fun element to the chat by allowing users to send various pre-designed stickers. For a comprehensive understanding and guide on implementing and using the Sticker Extension, refer to our specific guide on the [Sticker Extension](/fundamentals/stickers). + +Once you have successfully activated the [Sticker Extension](/fundamentals/stickers) from your CometChat Dashboard, the feature will automatically be incorporated into the [Message Composer](/ui-kit/react/message-composer) component of UI Kits. - + -### Collaborative Document +#### Stipop + +The Stipop extension integrates the world's trendiest sticker platform into your chat, allowing users to search for and send stickers from Stipop's extensive library. For a comprehensive understanding and guide on implementing and using the Stipop Extension, refer to our specific guide on the [Stipop Extension](/fundamentals/stickers-stipop). + +#### Tenor + +The Tenor extension allows users to search for and share GIFs from Tenor's library in their conversations. For a comprehensive understanding and guide on implementing and using the Tenor Extension, refer to our specific guide on the [Tenor Extension](/fundamentals/tenor). + +### Collaboration + +#### Collaborative Document With the Collaborative Document extension, users can work together on a shared document. This feature is essential for remote teams where document collaboration is a recurring requirement. For a comprehensive understanding and guide on implementing and using the Collaborative Document Extension, refer to our specific guide on the [Collaborative Document Extension](/fundamentals/collaborative-document). @@ -56,32 +140,79 @@ Once you have successfully activated the [Collaborative Document Extension](/fun -### Message Translation +#### Collaborative Whiteboard -The Message Translation extension in CometChat is designed to translate any message into your local locale. It eliminates language barriers, making the chat more inclusive. For a comprehensive understanding and guide on implementing and using the Message Translation Extension, refer to our specific guide on the [Message Translation Extension](/fundamentals/message-translation). +The Collaborative Whiteboard extension facilitates real-time collaboration. Users can draw, brainstorm, and share ideas on a shared digital whiteboard. For a comprehensive understanding and guide on implementing and using the Collaborative Whiteboard Extension, refer to our specific guide on the [Collaborative Whiteboard Extension](/fundamentals/collaborative-whiteboard). -Once you have successfully activated the [Message Translation Extension](/fundamentals/message-translation) from your CometChat Dashboard, the feature will automatically be incorporated into the Action Sheet of [MessageList Component](/ui-kit/react/message-list) component of UI Kits. +Once you have successfully activated the [Collaborative Whiteboard Extension](/fundamentals/collaborative-whiteboard) from your CometChat Dashboard, the feature will automatically be incorporated into the Action Sheet of the [Message Composer](/ui-kit/react/message-composer) component of UI Kits. - + -### Link Preview +### Security -The Link Preview extension provides a summary of the URL shared in the chat. It includes the title, a description, and a thumbnail image from the web page. For a comprehensive understanding and guide on implementing and using the Link Preview Extension, refer to our specific guide on the [Link Preview Extension](/fundamentals/link-preview). +#### Disappearing Messages -Once you have successfully activated the [Link Preview Extension](/fundamentals/link-preview) from your CometChat Dashboard, the feature will automatically be incorporated into the Message Bubble of [MessageList Component](/ui-kit/react/message-list) component of UI Kits. +The Disappearing Messages extension allows users to send messages that automatically disappear after a specified time interval. This works for both one-on-one and group messages. For a comprehensive understanding and guide on implementing and using the Disappearing Messages Extension, refer to our specific guide on the [Disappearing Messages Extension](/fundamentals/disappearing-messages). - - - +### Customer Support -### Thumbnail Generation +#### Chatwoot -The Thumbnail Generation extension automatically creates a smaller preview image whenever a larger image is shared, helping to reduce the upload/download time and bandwidth usage. For a comprehensive understanding and guide on implementing and using the Thumbnail Generation Extension, refer to our specific guide on the [Thumbnail Generation Extension](/fundamentals/thumbnail-generation). +The Chatwoot extension makes customer support seamless by allowing your users to communicate with your support team directly through CometChat, eliminating the need for a separate support interface. For a comprehensive understanding and guide on implementing and using the Chatwoot Extension, refer to our specific guide on the [Chatwoot Extension](/fundamentals/chatwoot). -Once you have successfully activated the [Thumbnail Generation Extension](/fundamentals/thumbnail-generation) from your CometChat Dashboard, the feature will automatically be incorporated into the Message Bubble of [MessageList Component](/ui-kit/react/message-list) component of UI Kits. +#### Intercom - - - +The Intercom extension integrates Intercom's customer support platform with CometChat, enabling users to chat with your support team using the same chat interface they use for regular conversations. For a comprehensive understanding and guide on implementing and using the Intercom Extension, refer to our specific guide on the [Intercom Extension](/fundamentals/intercom). + +### Smart Chat Features + +#### Conversation Starter + +Conversation Starter suggests AI-generated opening messages to help users begin a new chat. For a comprehensive understanding and guide on implementing and using Conversation Starter, refer to our specific guide on the [Conversation Starter](/fundamentals/ai-user-copilot/conversation-starter) and the [AI Features](/ui-kit/react/ai-features) overview. + +#### Smart Replies + +Smart Replies provide AI-generated response suggestions to keep conversations flowing. For a comprehensive understanding and guide on implementing and using Smart Replies, refer to our specific guide on the [Smart Replies](/fundamentals/ai-user-copilot/smart-replies) and the [AI Features](/ui-kit/react/ai-features) overview. + +#### Conversation Summary + +Conversation Summary generates an AI-written recap of a conversation when needed. For a comprehensive understanding and guide on implementing and using Conversation Summary, refer to our specific guide on the [Conversation Summary](/fundamentals/ai-user-copilot/conversation-summary) and the [AI Features](/ui-kit/react/ai-features) overview. + +--- + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Extension feature not appearing | Extension not activated in CometChat Dashboard | Enable the specific extension from your [Dashboard](/fundamentals/extensions-overview) | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but no extension UI | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| Stickers not showing in composer | Sticker extension not enabled | Activate [Sticker Extension](/fundamentals/stickers) in Dashboard | +| Polls option missing from action sheet | Polls extension not enabled | Activate [Polls Extension](/fundamentals/polls) in Dashboard | +| Link preview not rendering in messages | Link Preview extension not enabled | Activate [Link Preview Extension](/fundamentals/link-preview) in Dashboard | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Customize the composer where most extensions appear + + + Customize the message list for extension-rendered content + + + Explore core chat features like messaging and reactions + + + Explore AI-powered chat capabilities + + diff --git a/ui-kit/react/group-members.mdx b/ui-kit/react/group-members.mdx index ce7ec270f..999653e30 100644 --- a/ui-kit/react/group-members.mdx +++ b/ui-kit/react/group-members.mdx @@ -1,7 +1,40 @@ --- title: "Group Members" +description: "CometChatGroupMembers component displays all users in a group with their roles, scopes, and online status. Supports member management actions, custom views, filtering via GroupMembersRequestBuilder, and CSS styling." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; + +// Requires a CometChat.Group object + + +// With common props + console.log("Selected:", groupMember)} + selectionMode={SelectionMode.none} +/> +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatGroupMembers } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` +**Key props:** `group: CometChat.Group` (required), `onItemClick: (member: CometChat.GroupMember) => void`, `selectionMode: SelectionMode`, `groupMemberRequestBuilder: CometChat.GroupMembersRequestBuilder` +**CSS class:** `.cometchat-group-members` +**Events:** `CometChatGroupEvents` + + ## Overview `CometChatGroupMembers` is a Component that displays all users added or invited to a group, granting them access to group discussions, shared content, and collaborative features. Group members can communicate in real-time via messaging, voice and video calls, and other activities. They can interact, share files, and join calls based on group permissions set by the administrator or owner. @@ -10,6 +43,11 @@ title: "Group Members" + + +**Before using this component:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + *** ## Usage @@ -19,8 +57,8 @@ title: "Group Members" The following code snippet illustrates how you can directly incorporate the Group Members component into your Application. - -```tsx + +```tsx lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -42,17 +80,25 @@ export default GroupMembersDemo; - -```tsx -import { GroupMembersDemo } from "./GroupMembersDemo"; + +```jsx lines +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; +import React, { useState, useEffect } from "react"; -export default function App() { - return ( -
- -
- ); -} +const GroupMembersDemo = () => { + const [chatGroup, setChatGroup] = useState(null); + + useEffect(() => { + CometChat.getGroup("guid").then((group) => { + setChatGroup(group); + }); + }, []); + + return <>{chatGroup && }; +}; + +export default GroupMembersDemo; ```
@@ -65,7 +111,7 @@ export default function App() { [Actions](/ui-kit/react/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs. -##### 1. onSelect +#### 1. onSelect The `onSelect` action is activated when you select the done icon while in selection mode. This returns a list of all the group members that you have selected. @@ -73,7 +119,7 @@ This action does not come with any predefined behavior. However, you have the fl -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers, @@ -117,7 +163,7 @@ export default GroupMembersDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers, @@ -136,7 +182,7 @@ const GroupMembersDemo = () => { function handleOnSelect(groupMembers, selected) { console.log(groupMembers); - /** Your custom onSelect actions + /** Your custom onSelect actions **/ } return ( @@ -159,13 +205,13 @@ export default GroupMembersDemo; -##### 2. onItemClick +#### 2. onItemClick The `onItemClick` event is activated when you click on the Group Members List item. This action does not come with any predefined behavior. However, you have the flexibility to override this event and tailor it to suit your needs using the following code snippet. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -201,7 +247,7 @@ export default GroupMembersDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import { useEffect, useState } from "react"; @@ -238,13 +284,13 @@ export default GroupMembersDemo; -##### 3. onEmpty +#### 3. onEmpty This action allows you to specify a callback function to be executed when a certain condition, typically the absence of data or content, is met within the component or element. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -277,7 +323,7 @@ export default GroupMembersDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import { useEffect, useState } from "react"; @@ -311,13 +357,13 @@ export default GroupMembersDemo; -##### 4. onError +#### 4. onError This action doesn't change the behavior of the component but rather listens for any errors that occur in the Group Members component. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -350,7 +396,7 @@ export default GroupMembersDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import { useEffect, useState } from "react"; @@ -390,7 +436,7 @@ export default GroupMembersDemo; **Filters** allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK. -##### 1. GroupMembersRequestBuilder +#### 1. GroupMembersRequestBuilder The [GroupMembersRequestBuilder](/sdk/javascript/retrieve-group-members) enables you to filter and customize the group members list based on available parameters in GroupMembersRequestBuilder. This feature allows you to create more specific and targeted queries when fetching groups. The following are the parameters available in [GroupMembersRequestBuilder](/sdk/javascript/retrieve-group-members) @@ -406,7 +452,7 @@ In the example below, we are applying a filter to the Group Members by setting t -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -442,7 +488,7 @@ export default GroupMembersDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import { useEffect, useState } from "react"; @@ -479,7 +525,7 @@ export default GroupMembersDemo; -##### 2. SearchRequestBuilder +#### 2. SearchRequestBuilder The SearchRequestBuilder uses [GroupMembersRequestBuilder](/sdk/javascript/retrieve-group-members) enables you to filter and customize the search list based on available parameters in GroupMembersRequestBuilder. This feature allows you to keep uniformity between the displayed Group Members List and searched Group Members List. @@ -487,7 +533,7 @@ The SearchRequestBuilder uses [GroupMembersRequestBuilder](/sdk/javascript/retri -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -521,7 +567,7 @@ export default GroupMembersDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import { useEffect, useState } from "react"; @@ -572,7 +618,7 @@ Events emitted by the Group Members component is as follows. -```tsx +```tsx lines const ccGroupMemberBanned = CometChatGroupEvents.ccGroupMemberBanned.subscribe( (item: IGroupMemberKickedBanned) => { /** Your Code */ @@ -597,11 +643,9 @@ const ccGroupMemberScopeChanged = -*** - -```tsx +```tsx lines ccGroupMemberBanned?.unsubscribe(); ccGroupMemberKicked?.unsubscribe(); @@ -629,7 +673,7 @@ Using CSS you can customize the look and feel of the component in your app like -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -652,8 +696,8 @@ export default GroupMembersDemo; - -```css + +```css lines .cometchat-group-members .cometchat-list__header-title { background: #feede1; color: #f76808; @@ -700,7 +744,7 @@ These are a set of small functional customizations that allow you to fine-tune t -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -729,7 +773,7 @@ export default GroupMembersDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; import { useEffect, useState } from "react"; @@ -805,7 +849,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat, GroupMember } from "@cometchat/chat-sdk-javascript"; import React from "react"; import { @@ -883,8 +927,8 @@ export default GroupMembersDemo; - -```css + +```css lines .group-member-list-item { display: flex; min-width: 240px; @@ -983,7 +1027,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; @@ -1001,36 +1045,39 @@ const customTitleView = (member: CometChat.GroupMember) => { - -```css -.group-members__title-view{ - display: flex; - align-items: center; - gap: 4px; - align-self: stretch; - } - .group-members__title-view-name{ - overflow: hidden; - color: #141414; - text-overflow: ellipsis; - font:500 16px Roboto - } - .group-members__title-view-type{ - color: #FFF; - font: 600 8px Roboto; - display: flex; - height: 15px; - padding: 1px 3px; - justify-content: center; - align-items: center; - gap: 3px; - border-radius: 7px; - background: #09C26F; - } - .group-members__title-view-public .group-members__title-view-role{ - //add css based on roles - background: #0B7BEA; - } + +```css lines +.group-members__title-view { + display: flex; + align-items: center; + gap: 4px; + align-self: stretch; +} + +.group-members__title-view-name { + overflow: hidden; + color: #141414; + text-overflow: ellipsis; + font: 500 16px Roboto +} + +.group-members__title-view-type { + color: #FFF; + font: 600 8px Roboto; + display: flex; + height: 15px; + padding: 1px 3px; + justify-content: center; + align-items: center; + gap: 3px; + border-radius: 7px; + background: #09C26F; +} + +.group-members__title-view-public .group-members__title-view-role { + //add css based on roles + background: #0B7BEA; +} ``` @@ -1059,7 +1106,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat, GroupMember } from "@cometchat/chat-sdk-javascript"; import React from "react"; import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; @@ -1103,8 +1150,8 @@ export default GroupMembersDemo; - -```css + +```css lines .group-member-subtitle { overflow: hidden; color: #727272; @@ -1132,7 +1179,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers,CometChatAvatar } from "@cometchat/chat-uikit-react"; @@ -1158,41 +1205,47 @@ const customLeadingView = (member: CometChat.GroupMember): JSX.Element => { - -```css -.cometchat-group-members .cometchat-list-item .group-member__leading-view .cometchat-avatar__image, .cometchat-group-members .cometchat-list-item .group-member__leading-view .cometchat-avatar{ -border-radius: 8px; -height: 48px ; -width: 48px ; + +```css lines +.cometchat-group-members .cometchat-list-item .group-member__leading-view .cometchat-avatar__image, +.cometchat-group-members .cometchat-list-item .group-member__leading-view .cometchat-avatar { + border-radius: 8px; + height: 48px; + width: 48px; } -.group-member__leading-view-scope{ -display: flex; -width: 48px; -height: 15px; -padding: 1px 3px; -justify-content: center; -align-items: center; -color:#FFF; -font:600 8px/9.6px Roboto; -background:#FFAB00; -position:absolute; -bottom:-2px; + +.group-member__leading-view-scope { + display: flex; + width: 48px; + height: 15px; + padding: 1px 3px; + justify-content: center; + align-items: center; + color: #FFF; + font: 600 8px/9.6px Roboto; + background: #FFAB00; + position: absolute; + bottom: -2px; } -.group-member__leading-view{ -position: relative; + +.group-member__leading-view { + position: relative; } -.group-member__leading-view-participant .group-member__leading-view-scope{ -display: none; +.group-member__leading-view-participant .group-member__leading-view-scope { + display: none; } -.group-member__leading-view-owner .group-member__leading-view-scope{ -background: #0B7BEA; + +.group-member__leading-view-owner .group-member__leading-view-scope { + background: #0B7BEA; } -.group-member__leading-view-admin .group-member__leading-view-scope{ -background: #FFAB00; + +.group-member__leading-view-admin .group-member__leading-view-scope { + background: #FFAB00; } -.group-member__leading-view-moderator .group-member__leading-view-scope{ -background: #09C26F; + +.group-member__leading-view-moderator .group-member__leading-view-scope { + background: #09C26F; } ``` @@ -1222,7 +1275,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat, GroupMember } from "@cometchat/chat-sdk-javascript"; import React from "react"; import { @@ -1275,20 +1328,20 @@ export default GroupMembersDemo; - -```css + +```css lines .group-member-scope-tag { - display: flex; - padding: 4px 12px; - justify-content: center; - align-items: center; - gap: 20px; - border-radius: 1000px; - background: #edeafa; - overflow: hidden; - color: #6852d6; - text-overflow: ellipsis; - font: 400 12px Roboto; + display: flex; + padding: 4px 12px; + justify-content: center; + align-items: center; + gap: 20px; + border-radius: 1000px; + background: #edeafa; + overflow: hidden; + color: #6852d6; + text-overflow: ellipsis; + font: 400 12px Roboto; } ``` @@ -1312,7 +1365,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers,localize } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -1338,36 +1391,39 @@ const getHeaderView = () => { - -```css + +```css lines .cometchat-group-members__header { - display: flex; - width: 100%; - padding: 8px 16px; - align-items: center; - justify-content: space-between; - gap: 12px; - flex: 1 0 0; - align-self: stretch; - border-radius: 10px; - border: 1px solid #E8E8E8; - background: #EDEAFA; + display: flex; + width: 100%; + padding: 8px 16px; + align-items: center; + justify-content: space-between; + gap: 12px; + flex: 1 0 0; + align-self: stretch; + border-radius: 10px; + border: 1px solid #E8E8E8; + background: #EDEAFA; } + .cometchat-group-members__header__title { - overflow: hidden; - color: #141414; - text-overflow: ellipsis; - font: 700 24px Roboto; + overflow: hidden; + color: #141414; + text-overflow: ellipsis; + font: 700 24px Roboto; } + .cometchat-group-members__header .cometchat-button .cometchat-button__icon { - background: #6852D6; + background: #6852D6; } -.cometchat-group-members__header .cometchat-button{ - width: 24px; - border: none; - background: transparent; - border-radius: 0; - display: block; + +.cometchat-group-members__header .cometchat-button { + width: 24px; + border: none; + background: transparent; + border-radius: 0; + display: block; } ``` @@ -1391,7 +1447,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroupMembers, @@ -1440,19 +1496,19 @@ export default GroupMembersDemo; - -```css + +```css lines .cometchat-group-members .cometchat-menu-list__main-menu-item-icon { - height: 24px; - width: 24px; - -webkit-mask: url("./assets/delete.svg") center center no-repeat; - background: #f44649; + height: 24px; + width: 24px; + -webkit-mask: url("./assets/delete.svg") center center no-repeat; + background: #f44649; } .cometchat-group-members .cometchat-menu-list__menu, .cometchat-group-members .cometchat-menu-list__main-menu-item { - background: transparent; - box-shadow: none; + background: transparent; + box-shadow: none; } ``` @@ -1461,3 +1517,47 @@ export default GroupMembersDemo; *** + +## Component API Pattern + +| Customization Type | Prop Pattern | Example | +| --- | --- | --- | +| Callback actions | `on={(param) => {}}` | `onItemClick={(member) => {}}` | +| Data filtering | `groupMemberRequestBuilder={new CometChat.GroupMembersRequestBuilder("GUID")}` | `groupMemberRequestBuilder={builder}` | +| Toggle features | `hide={true\|false}` | `hideSearch={true}` | +| Custom rendering | `View={() => JSX}` | `itemView={(member) =>
...
}` | +| CSS overrides | Target `.cometchat-group-members` class in global CSS | `.cometchat-group-members { ... }` | + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| No members displayed | `group` prop not passed or invalid | Ensure a valid `CometChat.Group` object is passed to the `group` prop | +| Callback not firing | Wrong prop name or signature | Check the Actions section for exact prop name and parameter types | +| Custom view not appearing | Returning `null` or `undefined` from view prop | Ensure view function returns valid JSX | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Display and manage group lists + + + Display and manage user lists + + + Render messages in a chat view + + + Display recent conversations + + diff --git a/ui-kit/react/groups.mdx b/ui-kit/react/groups.mdx index 27bd1cd69..9d2ea9667 100644 --- a/ui-kit/react/groups.mdx +++ b/ui-kit/react/groups.mdx @@ -1,7 +1,39 @@ --- title: "Groups" +description: "CometChatGroups component displays a searchable list of all available groups with icons, names, member counts, and group type indicators. Supports selection modes, custom views, filtering via GroupsRequestBuilder, and CSS styling." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChatGroups } from "@cometchat/chat-uikit-react"; + +// Minimal usage + + +// With common props + console.log("Selected:", group)} + hideSearch={false} + selectionMode={SelectionMode.none} +/> +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatGroups } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` +**Key props:** `onItemClick: (group: CometChat.Group) => void`, `selectionMode: SelectionMode`, `groupsRequestBuilder: CometChat.GroupsRequestBuilder`, `hideSearch: boolean`, `hideGroupType: boolean` +**CSS class:** `.cometchat-groups` +**Events:** None (does not emit events directly) + + ## Overview The Groups is a Component, showcasing an accessible list of all available groups. It provides an integral search functionality, allowing you to locate any specific groups swiftly and easily. For each group listed, the group name is displayed by default, in conjunction with the group icon when available. Additionally, it provides a useful feature by displaying the number of members in each group as a subtitle, offering valuable context about group size and activity level. @@ -10,6 +42,11 @@ The Groups is a Component, showcasing an accessible list of all available groups + + +**Before using this component:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + The Groups component is composed of the following BaseComponents: | Components | Description | @@ -26,8 +63,8 @@ The Groups component is composed of the following BaseComponents: The following code snippet illustrates how you can directly incorporate the Groups component into your Application. - -```tsx + +```tsx lines import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -40,17 +77,16 @@ export default GroupsDemo; - -```tsx -import { GroupsDemo } from "./GroupsDemo"; + +```jsx lines +import { CometChatGroups } from "@cometchat/chat-uikit-react"; +import React from "react"; -export default function App() { - return ( -
- -
- ); -} +const GroupsDemo = () => { + return ; +}; + +export default GroupsDemo; ```
@@ -63,7 +99,7 @@ export default function App() { [Actions](/ui-kit/react/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs. -##### 1. onSelect +#### 1. onSelect The `onSelect` action is activated when you select the done icon while in selection mode. This returns the `group` object along with the boolean flag `selected` to indicate if the group was selected or unselected. @@ -71,7 +107,7 @@ This action does not come with any predefined behavior. However, you have the fl -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups, SelectionMode } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -95,7 +131,7 @@ export default GroupsDemo; -```js +```js lines import { CometChatGroups, SelectionMode } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -119,13 +155,13 @@ export default GroupsDemo; -##### 2. onItemClick +#### 2. onItemClick The `onItemClick` event is activated when you click on the Group List item. This action does not come with any predefined behavior. However, you have the flexibility to override this event and tailor it to suit your needs using the following code snippet. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -143,7 +179,7 @@ export default GroupsDemo; -```js +```js lines import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -161,13 +197,13 @@ export default GroupsDemo; -##### 3. onError +#### 3. onError This action doesn't change the behavior of the component but rather listens for any errors that occur in the Groups component. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -185,7 +221,7 @@ export default GroupsDemo; -```js +```js lines import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -207,7 +243,7 @@ export default GroupsDemo; **Filters** allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK. -##### 1. GroupsRequestBuilder +#### 1. GroupsRequestBuilder The [GroupsRequestBuilder](/sdk/javascript/retrieve-groups) enables you to filter and customize the group list based on available parameters in [GroupsRequestBuilder](/sdk/javascript/retrieve-groups). This feature allows you to create more specific and targeted queries when fetching groups. The following are the parameters available in [GroupsRequestBuilder](/sdk/javascript/retrieve-groups) @@ -225,7 +261,7 @@ In the example below, we are applying a filter to the Group List based on only j -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -246,7 +282,7 @@ export default GroupsDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -268,7 +304,7 @@ export default GroupsDemo; -##### 2. SearchRequestBuilder +#### 2. SearchRequestBuilder The SearchRequestBuilder uses [GroupsRequestBuilder](/sdk/javascript/retrieve-groups) enables you to filter and customize the search list based on available parameters in GroupsRequestBuilder. This feature allows you to keep uniformity between the displayed Groups List and searched Group List. @@ -276,7 +312,7 @@ The SearchRequestBuilder uses [GroupsRequestBuilder](/sdk/javascript/retrieve-gr -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -297,7 +333,7 @@ export default GroupsDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -347,7 +383,7 @@ Using CSS you can customize the look and feel of the component in your app like -```ts +```ts lines import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -361,7 +397,7 @@ export default GroupsDemo; -```js +```js lines import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -374,8 +410,8 @@ export default GroupsDemo; - -```css + +```css lines .cometchat .cometchat-groups .cometchat-list__header-title { background-color: #edeafa; color: #6852d6; @@ -445,7 +481,7 @@ These are a set of small functional customizations that allow you to fine-tune t -```ts +```ts lines import { CometChatGroups, TitleAlignment } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -465,7 +501,7 @@ export default GroupsDemo; -```js +```js lines import { CometChatGroups, TitleAlignment } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -528,7 +564,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -557,12 +593,12 @@ export default GroupsDemo; -```js +```js lines import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; const GroupsDemo = () => { - const getItemView = (group: CometChat.Group) => { + const getItemView = (group) => { return (
@@ -584,8 +620,8 @@ export default GroupsDemo; - -```css + +```css lines .group-list-item { display: flex; flex-direction: column; @@ -670,7 +706,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; @@ -688,40 +724,44 @@ const customTitleView = (group: CometChat.Group) => { - -```css -.groups__title-view{ -display: flex; -align-items: center; -gap: 4px; -align-self: stretch; + +```css lines +.groups__title-view { + display: flex; + align-items: center; + gap: 4px; + align-self: stretch; } -.groups__title-view-name{ -overflow: hidden; -color: #141414; -text-overflow: ellipsis; -font:500 16px Roboto + +.groups__title-view-name { + overflow: hidden; + color: #141414; + text-overflow: ellipsis; + font: 500 16px Roboto } -.groups__title-view-type{ -color: #FFF; -font: 600 8px Roboto; -display: flex; -height: 15px; -padding: 1px 3px; -justify-content: center; -align-items: center; -gap: 4px; -border-radius: 7px; -background: #09C26F; + +.groups__title-view-type { + color: #FFF; + font: 600 8px Roboto; + display: flex; + height: 15px; + padding: 1px 3px; + justify-content: center; + align-items: center; + gap: 4px; + border-radius: 7px; + background: #09C26F; } -.groups__title-view-public .groups__title-view-type{ -background: #0B7BEA; + +.groups__title-view-public .groups__title-view-type { + background: #0B7BEA; } -.groups__title-view-type img{ -background: #fff; -border-radius: 4px; -height: 12px; -width: 12px; + +.groups__title-view-type img { + background: #fff; + border-radius: 4px; + height: 12px; + width: 12px; } ``` @@ -751,7 +791,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -778,7 +818,7 @@ export default GroupsDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -804,8 +844,8 @@ export default GroupsDemo; - -```css + +```css lines .cometchat .cometchat-groups .group-subtitle { overflow: hidden; color: #727272; @@ -836,7 +876,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatGroups,CometChatAvatar } from "@cometchat/chat-uikit-react"; @@ -870,33 +910,35 @@ import { CometChatGroups,CometChatAvatar } from "@cometchat/chat-uikit-react"; - -```css - -.cometchat-groups .cometchat-list-item .groups__leading-view .cometchat-avatar__image, .cometchat-groups .cometchat-list-item .groups__leading-view .cometchat-avatar{ - border-radius: 8px; - height: 48px ; - width: 48px ; + +```css lines +.cometchat-groups .cometchat-list-item .groups__leading-view .cometchat-avatar__image, +.cometchat-groups .cometchat-list-item .groups__leading-view .cometchat-avatar { + border-radius: 8px; + height: 48px; + width: 48px; } -.groups__leading-view-info{ - display: flex; - width: 48px; - height: 15px; - padding: 1px 3px; - justify-content: center; - align-items: center; - color:#FFF; - font:600 8px/9.6px Roboto; - background:#FFAB00; - position:absolute; - bottom:-2px; +.groups__leading-view-info { + display: flex; + width: 48px; + height: 15px; + padding: 1px 3px; + justify-content: center; + align-items: center; + color: #FFF; + font: 600 8px/9.6px Roboto; + background: #FFAB00; + position: absolute; + bottom: -2px; } -.groups__leading-view-joined .groups__leading-view-info{ - background:#09C26F; + +.groups__leading-view-joined .groups__leading-view-info { + background: #09C26F; } -.groups__leading-view{ - position: relative; + +.groups__leading-view { + position: relative; } ``` @@ -918,7 +960,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -937,23 +979,24 @@ return
- -```css -.groups__trailing-view{ -display: flex; -padding: 4px 12px; -justify-content: center; -align-items: center; -border-radius: 1000px; -background: #EDEAFA; -overflow: hidden; -color: #6852D6; -text-overflow: ellipsis; -font:700 12px Roboto; + +```css lines +.groups__trailing-view { + display: flex; + padding: 4px 12px; + justify-content: center; + align-items: center; + border-radius: 1000px; + background: #EDEAFA; + overflow: hidden; + color: #6852D6; + text-overflow: ellipsis; + font: 700 12px Roboto; } -.cometchat-groups .cometchat-list-item__trailing-view{ -width: fit-content; -height: fit-content; + +.cometchat-groups .cometchat-list-item__trailing-view { + width: fit-content; + height: fit-content; } ``` @@ -977,7 +1020,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -995,7 +1038,7 @@ export default GroupsDemo; -```js +```js lines import { CometChatGroups } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -1012,8 +1055,8 @@ export default GroupsDemo; - -```css + +```css lines .group-header-view { height: 24px; width: 24px; @@ -1051,7 +1094,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChatGroups, CometChatOption } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -1077,12 +1120,12 @@ export default GroupsDemo; -```js +```js lines import { CometChatGroups, CometChatOption } from "@cometchat/chat-uikit-react"; import React from "react"; const GroupsDemo = () => { - const getOptions = (group: CometChat.Group): CometChatOption[] => { + const getOptions = (group) => { return [ new CometChatOption({ id: "delete", @@ -1102,28 +1145,73 @@ export default GroupsDemo; - -```css + +```css lines .cometchat .cometchat-groups .cometchat-menu-list__menu { - background: none; + background: none; } + .cometchat .cometchat-groups .cometchat-menu-list__main-menu-item-icon { - height: 24px; - width: 24px; - display: flex; - align-items: center; - justify-content: center; - border: none; - align-self: center; - background: #f44649; - flex-shrink: 0; - -webkit-mask: url("../assets/delete.svg") center center no-repeat; - mask: url("../assets/delete.svg") center center no-repeat; - -webkit-mask-size: contain; - mask-size: contain; + height: 24px; + width: 24px; + display: flex; + align-items: center; + justify-content: center; + border: none; + align-self: center; + background: #f44649; + flex-shrink: 0; + -webkit-mask: url("../assets/delete.svg") center center no-repeat; + mask: url("../assets/delete.svg") center center no-repeat; + -webkit-mask-size: contain; + mask-size: contain; } ``` + + +## Component API Pattern + +| Customization Type | Prop Pattern | Example | +| --- | --- | --- | +| Callback actions | `on={(param) => {}}` | `onItemClick={(group) => {}}` | +| Data filtering | `groupsRequestBuilder={new CometChat.GroupsRequestBuilder()}` | `groupsRequestBuilder={builder}` | +| Toggle features | `hide={true\|false}` | `hideSearch={true}` | +| Custom rendering | `View={() => JSX}` | `itemView={(group) =>
...
}` | +| CSS overrides | Target `.cometchat-groups` class in global CSS | `.cometchat-groups { ... }` | + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| Callback not firing | Wrong prop name or signature | Check the Actions section for exact prop name and parameter types | +| Custom view not appearing | Returning `null` or `undefined` from view prop | Ensure view function returns valid JSX | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + View and manage members within a group + + + Display and manage user lists + + + Display recent conversations + + + Render messages in a chat view + + diff --git a/ui-kit/react/guide-block-unblock-user.mdx b/ui-kit/react/guide-block-unblock-user.mdx index f758f45b3..decaeebd7 100644 --- a/ui-kit/react/guide-block-unblock-user.mdx +++ b/ui-kit/react/guide-block-unblock-user.mdx @@ -1,8 +1,20 @@ --- title: "Block/Unblock Users" sidebarTitle: "Block/Unblock Users" +description: "Implement block and unblock user functionality in CometChat React UI Kit with composer state management." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Key components:** `CometChatMessages` — uses `CometChat.blockUsers()` / `CometChat.unblockUsers()` SDK methods +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Events:** `CometChatUserEvents.ccUserBlocked`, `CometChatUserEvents.ccUserUnblocked` +- **UI helpers:** `CometChatConfirmDialog`, `CometChatToast` +- **Sample app:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) +- **Related:** [All Guides](/ui-kit/react/guide-overview) + + + Implement user blocking functionality to prevent unwanted communication in your React chat app. ## Overview @@ -279,11 +291,21 @@ CometChat.blockUsers([UID]).then( --- -## Next Steps & Further Reading - -- [CometChat React UI Kit Documentation](https://www.cometchat.com/docs/ui-kit/react/overview) -- [Sample App Repository](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) -- User Management Features -- Advanced Customization Guide -- Event Handling Documentation - +## Next Steps + + + + Display and manage user lists. + + + Customize the message input component. + + + Browse all feature and formatter guides. + + + Full working sample application on GitHub. + + + +*** diff --git a/ui-kit/react/guide-call-log-details.mdx b/ui-kit/react/guide-call-log-details.mdx index a029b601e..f35c4e5ae 100644 --- a/ui-kit/react/guide-call-log-details.mdx +++ b/ui-kit/react/guide-call-log-details.mdx @@ -1,8 +1,19 @@ --- title: "Call Log Details" sidebarTitle: "Call Log Details" +description: "Build a detailed call insights screen with metadata, participants, and recordings in CometChat React UI Kit." --- + +- **Packages:** `@cometchat/chat-uikit-react` + `@cometchat/calls-sdk-javascript` +- **Key components:** `CometChatCallDetails`, `CometChatCallDetailsInfo`, `CometChatCallDetailsParticipants`, `CometChatCallDetailsRecording` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` + Calls SDK installed +- **Purpose:** Detailed call insights screen with metadata, participants, and recordings +- **Sample app:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) +- **Related:** [All Guides](/ui-kit/react/guide-overview) + + + Display comprehensive call information and history when users select calls from the calls tab in your React chat app. ## Overview @@ -303,3 +314,22 @@ useEffect(() => { | Call history | `CometChatCallDetailsHistory` | [CometChatCallLogHistory.tsx](https://github.com/cometchat/cometchat-uikit-react/blob/v6/sample-app/src/components/CometChatCallLog/CometChatCallLogHistory.tsx) | | Tab navigation | `activeTab` state | [CometChatCallLogDetails.tsx](https://github.com/cometchat/cometchat-uikit-react/blob/v6/sample-app/src/components/CometChatCallLog/CometChatCallLogDetails.tsx) | | User status monitoring| `CometChat.addUserListener()` | [CometChatCallLogDetails.tsx](https://github.com/cometchat/cometchat-uikit-react/blob/v6/sample-app/src/components/CometChatCallLog/CometChatCallLogDetails.tsx) | + +## Next Steps + + + + The call logs component reference. + + + Overview of calling capabilities. + + + Browse all feature and formatter guides. + + + Full working sample application on GitHub. + + + +*** diff --git a/ui-kit/react/guide-group-chat.mdx b/ui-kit/react/guide-group-chat.mdx index b62e735ec..c9c232af6 100644 --- a/ui-kit/react/guide-group-chat.mdx +++ b/ui-kit/react/guide-group-chat.mdx @@ -1,8 +1,19 @@ --- title: "Group Chat" sidebarTitle: "Group Chat" +description: "Implement group management including create, join, members, roles, and ownership transfer in CometChat React UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Key components:** `CometChatGroups`, `CometChatGroupMembers`, `CometChatCreateGroup`, `CometChatJoinGroup` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Features:** Create public/private/password-protected groups, manage members, roles, ownership transfer +- **Sample app:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) +- **Related:** [All Guides](/ui-kit/react/guide-overview) + + + Implement comprehensive group management functionality including creation, joining, member management, and administrative controls in your React chat app. --- @@ -337,11 +348,21 @@ const handleGroupOperation = async (operation: () => Promise) => { --- -## Next Steps & Further Reading - -- [CometChat React UI Kit Documentation](https://www.cometchat.com/docs/ui-kit/react/overview) -- [Sample App Repository](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) -- Group Management Features -- Advanced Customization Guide -- Member Management Documentation - +## Next Steps + + + + Display and manage group lists. + + + Display and manage group member lists. + + + Browse all feature and formatter guides. + + + Full working sample application on GitHub. + + + +*** diff --git a/ui-kit/react/guide-message-privately.mdx b/ui-kit/react/guide-message-privately.mdx index 1d0add7ad..4054ae49e 100644 --- a/ui-kit/react/guide-message-privately.mdx +++ b/ui-kit/react/guide-message-privately.mdx @@ -1,8 +1,19 @@ --- title: "Message Privately" sidebarTitle: "Message Privately" +description: "Launch a direct 1:1 chat from a group member profile in CometChat React UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Key components:** `CometChatMessages`, `CometChatGroupMembers`, `CometChatMessageComposer`, `CometChatMessageList`, `CometChatMessageHeader` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Purpose:** Launch a direct 1:1 chat from a group member profile +- **Sample app:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) +- **Related:** [All Guides](/ui-kit/react/guide-overview) + + + Enable users to initiate private conversations with group members directly from group chat interfaces. ## Overview @@ -316,10 +327,21 @@ const startPrivateChatFromGroup = async (user: CometChat.User, group: CometChat. --- -## Next Steps & Further Reading - -- [CometChat React UI Kit Documentation](https://www.cometchat.com/docs/ui-kit/react/overview) -- [Sample App Repository](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) -- Group Management Features -- User Management Features -- Message Types & Features +## Next Steps + + + + Display and manage group member lists. + + + Render real-time message threads. + + + Browse all feature and formatter guides. + + + Full working sample application on GitHub. + + + +*** diff --git a/ui-kit/react/guide-new-chat.mdx b/ui-kit/react/guide-new-chat.mdx index 54ee2e6b2..d9a341c26 100644 --- a/ui-kit/react/guide-new-chat.mdx +++ b/ui-kit/react/guide-new-chat.mdx @@ -1,8 +1,19 @@ --- title: "New Chat" sidebarTitle: "New Chat" +description: "Build a unified new chat entry point for starting 1:1 or group conversations in CometChat React UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Key components:** `CometChatUsers`, `CometChatGroups`, `CometChatJoinGroup`, `CometChatSelector` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Purpose:** Unified new chat entry point for starting 1:1 or group conversations +- **Sample app:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) +- **Related:** [All Guides](/ui-kit/react/guide-overview) + + + Enable users to create new conversations with individual users or join existing groups in your React chat app. ## Overview @@ -257,9 +268,21 @@ const joinGroup = (e) => { --- -## Next Steps & Further Reading - -- [CometChat React UI Kit Documentation](https://www.cometchat.com/docs/ui-kit/react/overview) -- [Sample App Repository](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) -- User Management Features -- Group Management Features +## Next Steps + + + + Display and manage conversation lists. + + + Display and manage group lists. + + + Browse all feature and formatter guides. + + + Full working sample application on GitHub. + + + +*** diff --git a/ui-kit/react/guide-overview.mdx b/ui-kit/react/guide-overview.mdx index 10ab044fd..d619e5f0b 100644 --- a/ui-kit/react/guide-overview.mdx +++ b/ui-kit/react/guide-overview.mdx @@ -1,7 +1,17 @@ --- title: "Overview" sidebarTitle: "Overview" +description: "Index of task-oriented feature guides for the CometChat React UI Kit." --- + + +- **Package:** `@cometchat/chat-uikit-react` +- **Purpose:** Index of task-oriented feature guides for the React UI Kit +- **Sample app:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) +- **Components:** [Components Overview](/ui-kit/react/components-overview) +- **Guides:** [Block/Unblock](/ui-kit/react/guide-block-unblock-user) | [Call Log Details](/ui-kit/react/guide-call-log-details) | [Group Chat](/ui-kit/react/guide-group-chat) | [Message Privately](/ui-kit/react/guide-message-privately) | [New Chat](/ui-kit/react/guide-new-chat) | [Search Messages](/ui-kit/react/guide-search-messages) | [Threaded Messages](/ui-kit/react/guide-threaded-messages) + + > This page indexes focused, task‑oriented feature guides for the React UI Kit. Each guide shows how to implement a specific capability end‑to‑end using UI components. ## When to Use These Guides @@ -26,3 +36,21 @@ Use these guides after completing the base [Getting Started](/ui-kit/react/react Need another guide? Open a request via our [Developer Community](http://community.cometchat.com/) or Support. +--- + +## Next Steps + + + + Set up the React UI Kit + + + Explore all UI components + + + Customize themes and styling + + + Handle UI Kit events + + diff --git a/ui-kit/react/guide-search-messages.mdx b/ui-kit/react/guide-search-messages.mdx index 072126f4f..97bdf7bf2 100644 --- a/ui-kit/react/guide-search-messages.mdx +++ b/ui-kit/react/guide-search-messages.mdx @@ -1,8 +1,19 @@ --- title: "Search Messages" sidebarTitle: "Search Messages" +description: "Add full-text message search across conversations with result routing in CometChat React UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Key components:** `CometChatSearchMessages`, `CometChatMessageList`, `CometChatMessageComposer`, `CometChatMessageHeader` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Purpose:** Full-text message search across conversations with result routing and navigation +- **Sample app:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) +- **Related:** [All Guides](/ui-kit/react/guide-overview) + + + Enable users to search messages within conversations and group chats using CometChat's React UI Kit. ## Overview @@ -178,9 +189,21 @@ try { --- -## Next Steps & Further Reading - -- [CometChat React UI Kit Documentation](https://www.cometchat.com/docs/ui-kit/react/overview) -- [Sample App Repository](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) -- Message Management Features -- Advanced Search Features +## Next Steps + + + + The search component reference. + + + Render real-time message threads. + + + Browse all feature and formatter guides. + + + Full working sample application on GitHub. + + + +*** diff --git a/ui-kit/react/guide-threaded-messages.mdx b/ui-kit/react/guide-threaded-messages.mdx index 50c06c07f..11c6f7e05 100644 --- a/ui-kit/react/guide-threaded-messages.mdx +++ b/ui-kit/react/guide-threaded-messages.mdx @@ -1,8 +1,20 @@ --- title: "Threaded Messages" sidebarTitle: "Threaded Messages" +description: "Implement threaded message replies with parent context, reply list, and focused thread composer in CometChat React UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Key components:** `CometChatThreadedMessages`, `CometChatThreadHeader`, `CometChatMessageList`, `CometChatMessageComposer` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Purpose:** Threaded message replies with parent context, reply list, and focused thread composer +- **Entry point:** `CometChatMessages.onThreadRepliesClick` opens thread view from group messages +- **Sample app:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) +- **Related:** [All Guides](/ui-kit/react/guide-overview) + + + Enable organized threaded conversations within group chats using CometChat's React UI Kit. ## Overview @@ -211,5 +223,19 @@ useEffect(() => { ## Next Steps -- Explore [CometChat React UI Kit Docs](https://www.cometchat.com/docs/ui-kit/react/overview) -- Check the [Sample App Repo](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) + + + Render real-time message threads. + + + Customize the thread header component. + + + Browse all feature and formatter guides. + + + Full working sample application on GitHub. + + + +*** diff --git a/ui-kit/react/incoming-call.mdx b/ui-kit/react/incoming-call.mdx index e55f9f37f..cf90bf14c 100644 --- a/ui-kit/react/incoming-call.mdx +++ b/ui-kit/react/incoming-call.mdx @@ -1,7 +1,39 @@ --- title: "Incoming Call" +description: "Display and manage incoming voice and video calls with accept/decline controls using the CometChatIncomingCall component." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; + +// Minimal usage — auto-detects incoming calls + + +// With custom handlers + console.log("Call accepted")} + onDecline={() => console.log("Call declined")} + disableSoundForCalls={false} +/> +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatIncomingCall } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` +**Key props:** `onAccept` (callback), `onDecline` (callback), `call` (CometChat.Call), `disableSoundForCalls` (boolean), `callSettingsBuilder` (function) +**CSS class:** `.cometchat-incoming-call` +**Events:** `ccCallRejected`, `ccCallAccepted`, `ccCallEnded` + + ## Overview The `Incoming call` is a Component that serves as a visual representation when the user receives an incoming call, such as a voice call or video call, providing options to answer or decline the call. @@ -10,6 +42,7 @@ The `Incoming call` is a Component that serves as a visual representation when t + The `Incoming Call` is comprised of the following base components: | Components | Description | @@ -18,13 +51,18 @@ The `Incoming Call` is comprised of the following base components: | cometchat-button | This component represents a button with optional icon and text. | | cometchat-avatar | This component component displays an image or user's avatar with fallback to the first two letters of the username. | + + +**Before using this component:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + ## Usage ### Integration - -```tsx + +```tsx lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -37,19 +75,16 @@ export default IncomingCallsDemo; - -```tsx -import { IncomingCallsDemo } from "./IncomingCallsDemo"; + +```jsx lines +import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; +import React from "react"; -export default function App() { - return ( -
-
- -
-
- ); -} +const IncomingCallsDemo = () => { + return ; +}; + +export default IncomingCallsDemo; ```
@@ -60,13 +95,13 @@ export default function App() { [Actions](/ui-kit/react/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs. -##### 1. onAccept +#### 1. onAccept `onAccept` is triggered when you click the accept button of the `Incoming Call` component. You can override this action using the following code snippet. -```ts +```ts lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -84,7 +119,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -103,13 +138,13 @@ export default IncomingCallsDemo; -##### 2. onDecline +#### 2. onDecline `onDecline` is triggered when you click the Decline button of the `Incoming Call` component. You can override this action using the following code snippet. -```ts +```ts lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -127,7 +162,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -146,13 +181,13 @@ export default IncomingCallsDemo; -##### 3. onError +#### 3. onError This action doesn't change the behavior of the component but rather listens for any errors that occur in the Incoming Call component. -```ts +```ts lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -170,7 +205,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -197,7 +232,7 @@ You can set `CallSettingsBuilder` in the Incoming Call Component to customise th -```ts +```ts lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -221,7 +256,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -260,7 +295,7 @@ The list of events emitted by the Incoming Call component is as follows. -```tsx +```tsx lines const ccCallRejected = CometChatCallEvents.ccCallRejected.subscribe( (call: CometChat.Call) => { //Your Code @@ -288,7 +323,7 @@ const ccCallEnded = CometChatCallEvents.ccCallEnded.subscribe( -```tsx +```tsx lines ccCallRejected?.unsubscribe(); ccCallAccepted?.unsubscribe(); @@ -318,7 +353,7 @@ Using CSS you can customize the look and feel of the component in your app like -```ts +```ts lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -332,7 +367,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -345,8 +380,8 @@ export default IncomingCallsDemo; - -```css + +```css lines .cometchat-incoming-call { display: flex; width: 555px; @@ -469,7 +504,7 @@ Here is a code snippet demonstrating how you can customize the functionality of -```ts +```ts lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -487,7 +522,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -528,7 +563,7 @@ Property `subtitleView` is a function that renders a JSX element to display the -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -547,7 +582,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -581,7 +616,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAvatar, CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -604,7 +639,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAvatar, CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -626,8 +661,8 @@ export default IncomingCallsDemo; - -```css + +```css lines .cometchat-incoming-call__avatar { display: none; } @@ -651,7 +686,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -678,7 +713,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -704,8 +739,8 @@ export default IncomingCallsDemo; - -```css + +```css lines .incoming-call__title-wrapper { display: flex; width: 370px; @@ -756,7 +791,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -780,7 +815,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -803,8 +838,8 @@ export default IncomingCallsDemo; - -```css + +```css lines .incoming-call__avatar { display: flex; height: 62px; @@ -845,7 +880,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAvatar, CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -876,7 +911,7 @@ export default IncomingCallsDemo; -```js +```js lines import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAvatar, CometChatIncomingCall } from "@cometchat/chat-uikit-react"; import React from "react"; @@ -906,8 +941,8 @@ export default IncomingCallsDemo; - -```css + +```css lines .incoming-call__itemview { display: flex; flex-direction: column; @@ -945,3 +980,38 @@ export default IncomingCallsDemo; + + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but no incoming call shown | User not logged in or no active incoming call | Call `CometChatUIKit.login("UID")` after init. The component auto-detects incoming calls. | +| Callback not firing | Wrong prop name or signature | Check the Actions section for exact prop name and parameter types | +| Custom view not appearing | Returning `null` or `undefined` from view prop | Ensure view function returns valid JSX | +| No ringtone playing | `disableSoundForCalls` set to `true` or custom sound path invalid | Set `disableSoundForCalls={false}` and verify custom sound file path | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Manage outgoing voice and video calls + + + Add voice and video call buttons to your chat + + + Display call history and call log details + + + Overview of all calling capabilities + + diff --git a/ui-kit/react/link/changelog.mdx b/ui-kit/react/link/changelog.mdx index 8c698a26d..e3acadbd7 100644 --- a/ui-kit/react/link/changelog.mdx +++ b/ui-kit/react/link/changelog.mdx @@ -1,4 +1,4 @@ --- title: "Changelog" url: "https://github.com/cometchat/cometchat-uikit-react/releases?q=v6&expanded=true" ---- \ No newline at end of file +--- diff --git a/ui-kit/react/link/figma.mdx b/ui-kit/react/link/figma.mdx index 172dd3788..784cf16e7 100644 --- a/ui-kit/react/link/figma.mdx +++ b/ui-kit/react/link/figma.mdx @@ -1,4 +1,4 @@ --- title: "Figma Design" url: "https://www.figma.com/community/file/1442863561340379957/cometchat-ui-kit-for-web" ---- \ No newline at end of file +--- diff --git a/ui-kit/react/link/sample.mdx b/ui-kit/react/link/sample.mdx index 3f7e45be6..d7748ae0d 100644 --- a/ui-kit/react/link/sample.mdx +++ b/ui-kit/react/link/sample.mdx @@ -1,4 +1,4 @@ --- title: "React Sample App" url: "https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app" ---- \ No newline at end of file +--- diff --git a/ui-kit/react/localize.mdx b/ui-kit/react/localize.mdx index 45f62ad52..42ca888c2 100644 --- a/ui-kit/react/localize.mdx +++ b/ui-kit/react/localize.mdx @@ -1,8 +1,20 @@ --- title: "Localization" sidebarTitle: "Localize" +description: "Configure multi-language localization, custom translations, and date/time formatting in CometChat React UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Import:** `import { CometChatLocalize } from "@cometchat/chat-uikit-react";` +- **Set language:** `CometChatLocalize.setCurrentLanguage("fr")` +- **Init with config:** `CometChatLocalize.init({ language: "es", fallbackLanguage: "en-US", disableAutoDetection: false })` +- **Add translations:** `CometChatLocalize.addTranslation({ "en-US": { "welcome_message": "Welcome!" } })` +- **19 supported languages:** en-US, en-GB, nl, fr, de, hi, it, ja, ko, pt, ru, es, tr, zh, zh-TW, ms, sv, lt, hu +- **Date formatting:** Use `CalendarObject` for custom date/time patterns +- **Source:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/blob/v6/src/resources/CometChatLocalize/cometchat-localize.ts) + + ## **Overview** React UI Kit provides **multi-language localization** to **adapt** the UI elements based on the user's preferred language settings. The **CometChatLocalize** class allows developers to: @@ -391,4 +403,40 @@ To apply a **custom date format** only within a specific component. /> ``` -*** \ No newline at end of file + +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| UI text not translated | Language code not matching supported codes | Check the supported languages table for exact codes (e.g., `en-US` not `en`) | +| Custom translations not appearing | `addTranslation` called before `init` | Call `CometChatLocalize.init()` first, then `addTranslation()` | +| Date/time format unchanged | `disableDateTimeLocalization` set to `true` | Set `disableDateTimeLocalization: false` in init config | +| Component-level CalendarObject ignored | Prop name mismatch | Check the component docs for the exact prop name (e.g., `lastActiveAtDateTimeFormat`) | +| Missing translation key shows raw key | No `missingKeyHandler` configured | Add a `missingKeyHandler` function in init config | + + + + +*** + +## Next Steps + + + + Configure audio cues for calls and messages. + + + Customize colors, fonts, and styles. + + + Explore all available prebuilt UI components. + + + Init, login, logout, and other UI Kit methods. + + + +*** diff --git a/ui-kit/react/mentions-formatter-guide.mdx b/ui-kit/react/mentions-formatter-guide.mdx index f5e8d6860..1d0626569 100644 --- a/ui-kit/react/mentions-formatter-guide.mdx +++ b/ui-kit/react/mentions-formatter-guide.mdx @@ -1,7 +1,18 @@ --- title: "Mentions Formatter" +description: "Add @mentions with styled tokens, suggestion list, and click handling in CometChat React UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Key class:** `CometChatMentionsFormatter` (extends `CometChatTextFormatter`) +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Purpose:** Format @mentions with styled tokens, suggestion list, and click handling for users and group members +- **Sample app:** [GitHub](https://github.com/cometchat/cometchat-uikit-react/tree/v6/sample-app) +- **Related:** [Custom Text Formatter](/ui-kit/react/custom-text-formatter-guide) | [All Guides](/ui-kit/react/guide-overview) + + + ## Overview The `CometChatMentionsFormatter` class is a part of the CometChat UI Kit, a ready-to-use chat UI component library for integrating CometChat into your React applications. This class provides functionality to format mentions within text messages displayed in the chat interface. Mentions allow users to reference other users within a conversation, providing a convenient way to direct messages or involve specific participants. @@ -48,3 +59,22 @@ mentionsFormatter.setCometChatUserGroupMembers(userList); The `formattedMessage` now contains HTML with styled mentions, ready to be inserted into your message component for display. Below is an example demonstrating how to use the `CometChatMentionsFormatter` class in components such as [CometChatConversations](/ui-kit/react/conversations), [CometChatMessageList](/ui-kit/react/message-list), [CometChatMessageComposer](/ui-kit/react/message-composer). + +## Next Steps + + + + Build custom inline text patterns. + + + Render real-time message threads. + + + Browse all feature and formatter guides. + + + Full working sample application on GitHub. + + + +*** diff --git a/ui-kit/react/message-composer.mdx b/ui-kit/react/message-composer.mdx index 67249e000..7687fe9ed 100644 --- a/ui-kit/react/message-composer.mdx +++ b/ui-kit/react/message-composer.mdx @@ -1,7 +1,36 @@ --- title: "Message Composer" +description: "CometChatMessageComposer component provides a rich text input for composing and sending messages including text, media, attachments, reactions, mentions, and voice notes. Supports custom actions, AI features, and CSS styling." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; + +// For a user chat + + +// For a group chat + +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatMessageComposer } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` or `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` +**Key props:** `user: CometChat.User`, `group: CometChat.Group`, `text: string`, `parentMessageId: number`, `hideVoiceRecording: boolean` +**CSS class:** `.cometchat-message-composer` +**Events:** `CometChatMessageEvents` + + ## Overview MessageComposer is a Component that enables users to write and send a variety of messages, including text, image, video, and custom messages. @@ -12,6 +41,11 @@ Features such as **Attachments**, and **Message Editing** are also supported by + + +**Before using this component:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + ## Usage ### Integration @@ -19,8 +53,8 @@ Features such as **Attachments**, and **Message Editing** are also supported by The following code snippet illustrates how you can directly incorporate the MessageComposer component into your app. - -```tsx + +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; @@ -43,18 +77,25 @@ export function MessageComposerDemo() { - -```tsx -import { MessageComposerDemo } from "./MessageComposerDemo"; + +```jsx lines +import React, { useState, useEffect } from "react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; -export default function App() { - return ( -
-
- -
+export function MessageComposerDemo() { + const [chatUser, setChatUser] = useState(null); + useEffect(() => { + CometChat.getUser("uid").then((user) => { + setChatUser(user); + }); + }, []); + + return chatUser ? ( +
+
- ); + ) : null; } ``` @@ -66,13 +107,13 @@ export default function App() { [Actions](/ui-kit/react/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs. -##### 1. OnSendButtonClick +#### 1. OnSendButtonClick The `OnSendButtonClick` event gets activated when the send message button is clicked. It has a predefined function of sending messages entered in the composer `EditText`. However, you can overide this action with the following code snippet. - -```tsx + +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; @@ -100,15 +141,44 @@ export function MessageComposerDemo() { + +```jsx lines +import React from "react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; + +export function MessageComposerDemo() { + const [chatUser, setChatUser] = React.useState(null); + + React.useEffect(() => { + CometChat.getUser("uid").then((user) => { + setChatUser(user); + }); + }, []); + + function handleSendButtonClick(message) { + console.log("your custom on send buttonclick action"); + } + + return chatUser ? ( +
+ +
+ ) : null; +} +``` + +
+
-##### 2. onError +#### 2. onError This action doesn't change the behavior of the component but rather listens for any errors that occur in the MessageList component. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; @@ -138,13 +208,13 @@ export function MessageComposerDemo() { -##### 3. onTextChange +#### 3. onTextChange This event is triggered as the user starts typing in the Message Composer. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; @@ -177,13 +247,13 @@ export function MessageComposerDemo() { -##### 4. Custom Mentions Request Builders +#### 4. Custom Mentions Request Builders You can customize how mentioned users and group members are fetched by providing custom request builders. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; @@ -261,7 +331,7 @@ Adding `CometChatMessageEvents` Listener's -```js +```js lines import { CometChatMessageEvents } from "@cometchat/chat-uikit-react"; const ccMessageEdited = CometChatMessageEvents.ccMessageEdited.subscribe(() => { @@ -287,7 +357,7 @@ Removing `CometChatMessageEvents` Listener's -```js +```js lines ccMessageEdited?.unsubscribe(); ccReplyToMessage?.unsubscribe(); ccMessageSent?.unsubscribe(); @@ -315,7 +385,7 @@ To modify the styling, you can customise the css of MessageComposer Component. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; @@ -326,7 +396,7 @@ import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; -```css +```css lines .cometchat-message-composer .cometchat-message-composer__input { font-family: "SF Pro"; } @@ -352,7 +422,7 @@ These are a set of small functional customizations that allow you to fine-tune t -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; @@ -423,7 +493,7 @@ Use the following code to achieve the customization shown above. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -465,7 +535,7 @@ function getAttachments() { -```css +```css lines .cometchat-message-composer__secondary-button-view-attachment-button .cometchat-action-sheet { border: none; @@ -520,7 +590,7 @@ Use the following code to achieve the customization shown above. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -570,7 +640,7 @@ Use the following code to achieve the customization shown above. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -593,7 +663,7 @@ const sendButtonView = ( -```css +```css lines .cometchat-message-composer div:not([class]) .message-composer__send-button @@ -635,7 +705,7 @@ Use the following code to achieve the customization shown above. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; @@ -657,7 +727,7 @@ const getHeaderView = () => { -```css +```css lines .cometchat-message-composer .message-composer__header-view { display: flex; align-items: center; @@ -711,7 +781,7 @@ Assigns the list of text formatters. If the provided list is not null, it sets t -```ts +```ts lines import { CometChatTextFormatter } from "@cometchat/chat-uikit-react"; import DialogHelper from "./Dialog"; import { CometChat } from "@cometchat/chat-sdk-javascript"; @@ -825,7 +895,7 @@ export default ShortcutFormatter; -```tsx +```tsx lines import React from "react"; import ReactDOM from "react-dom"; @@ -890,7 +960,7 @@ export default class DialogHelper { -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageComposer } from "@cometchat/chat-uikit-react"; @@ -920,3 +990,36 @@ export function MessageComposerDemo() { *** + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but can't send messages | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| Attachments not working | File permissions or browser restrictions | Ensure the browser allows file access | +| Voice recording not available | `hideVoiceRecording={true}` is set or browser doesn't support MediaRecorder | Check prop and browser compatibility | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Render messages in a chat view + + + Customize message bubble rendering + + + Display user/group details in the toolbar + + + Add stickers, polls, and more to the composer + + diff --git a/ui-kit/react/message-header.mdx b/ui-kit/react/message-header.mdx index 28d7d0c85..631ba1311 100644 --- a/ui-kit/react/message-header.mdx +++ b/ui-kit/react/message-header.mdx @@ -1,7 +1,36 @@ --- title: "Message Header" +description: "CometChatMessageHeader component displays user or group details in the toolbar including avatar, name, status, typing indicator, and back navigation. Supports custom views and CSS styling." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; + +// For a user chat + + +// For a group chat + +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatMessageHeader } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` or `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` +**Key props:** `user: CometChat.User`, `group: CometChat.Group`, `hideBackButton: boolean`, `hideUserStatus: boolean` +**CSS class:** `.cometchat-message-header` +**Events:** None (does not emit events directly) + + ## Overview `MessageHeader` is a Component that showcases the [User](/sdk/javascript/users-overview) or [Group](/sdk/javascript/groups-overview) details in the toolbar. Furthermore, it also presents a typing indicator and a back navigation button for ease of use. @@ -10,6 +39,11 @@ title: "Message Header" + + +**Before using this component:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + The `MessageHeader` is comprised of the following components: | Component | Description | @@ -22,8 +56,8 @@ The `MessageHeader` is comprised of the following components: ### Integration - -```tsx + +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; @@ -44,18 +78,23 @@ export function MessageHeaderDemo() { - -```tsx -import { MessageHeaderDemo } from "./MessageHeaderDemo"; + +```jsx lines +import React, { useState, useEffect } from "react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; -export default function App() { - return ( -
-
- -
-
- ); +export function MessageHeaderDemo() { + const [chatUser, setChatUser] = useState(null); + useEffect(() => { + CometChat.getUser("uid").then((user) => { + setChatUser(user); + }); + }, []); + + return chatUser ? ( +
{chatUser && }
+ ) : null; } ``` @@ -77,7 +116,7 @@ In this example, we are employing the `onBack` action. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; @@ -120,7 +159,7 @@ In this example, we are employing the `onError` action. -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; @@ -152,13 +191,13 @@ export function MessageHeaderDemo() { *** -##### 3. onSearchOptionClicked +#### 3. onSearchOptionClicked The `onSearchOptionClicked` event is triggered when the user clicks the search option. It does not have a default behavior. However, you can override its behavior using the following code snippet. -```tsx +```tsx lines import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; const handleSearchClick = () => { @@ -180,7 +219,7 @@ const handleSearchClick = () => { -```tsx +```tsx lines import { MessageHeaderDemo } from "@cometchat/chat-uikit-react"; const getOnItemClick = () => { @@ -224,7 +263,7 @@ To customize the appearance, you can customise css of `CometChatMessageHeader` -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; @@ -235,8 +274,8 @@ import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; - -```css + +```css lines .cometchat-message-header .cometchat-list-item .cometchat-avatar { background: #f0999b; border-radius: 8px; @@ -258,7 +297,7 @@ Here is a code snippet demonstrating how you can customize the functionality of -```ts +```ts lines import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; ; @@ -299,7 +338,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -328,8 +367,8 @@ const CustomItemView = ( - -```css + +```css lines .cometchat-message-header .cometchat-list-item .cometchat-avatar { border-radius: 8px; } @@ -353,7 +392,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; @@ -377,27 +416,24 @@ function CustomTitleView() { - -```css + +```css lines .cometchat-message-header .message-header__title-view { - display: flex; - gap: 4px; - width: 100%; + display: flex; + gap: 4px; + width: 100%; } -.cometchat-message-header - .message-header__title-view - .message-header__title-view-name { - color: #141414; - font: 500 16px/19.2px Roboto; - text-align: left; +.cometchat-message-header .message-header__title-view .message-header__title-view-name { + color: #141414; + font: 500 16px/19.2px Roboto; + text-align: left; } -.cometchat-message-header - .message-header__title-view - .message-header__title-view-status { - color: #6852d6; - font: 400 16px/19.2px Roboto; - text-align: left; + +.cometchat-message-header .message-header__title-view .message-header__title-view-status { + color: #6852d6; + font: 400 16px/19.2px Roboto; + text-align: left; } ``` @@ -419,7 +455,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; @@ -450,7 +486,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -475,36 +511,31 @@ function CustomLeadingView() { - -```css -.cometchat-message-header - .cometchat-list-item - .message-header__leading-view - .cometchat-avatar__image, -.cometchat-message-header - .cometchat-list-item - .message-header__leading-view - .cometchat-avatar { - border-radius: 8px; - height: 48px; - width: 48px; + +```css lines +.cometchat-message-header .cometchat-list-item .message-header__leading-view .cometchat-avatar__image, +.cometchat-message-header .cometchat-list-item .message-header__leading-view .cometchat-avatar { + border-radius: 8px; + height: 48px; + width: 48px; } .message-header__leading-view-role { - display: flex; - width: 48px; - height: 15px; - padding: 1px 3px; - justify-content: center; - align-items: center; - color: #fff; - font: 600 8px/9.6px Roboto; - background: #0b7bea; - position: absolute; - bottom: -2px; + display: flex; + width: 48px; + height: 15px; + padding: 1px 3px; + justify-content: center; + align-items: center; + color: #fff; + font: 600 8px/9.6px Roboto; + background: #0b7bea; + position: absolute; + bottom: -2px; } + .message-header__leading-view { - position: relative; + position: relative; } ``` @@ -526,7 +557,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -556,21 +587,17 @@ function CustomTrailingButtonView() { - -```css -.cometchat-message-header - .cometchat-list-item__trailing-view - .cometchat-button { - background: transparent; - height: 24px; - width: 24px; - padding: 0; + +```css lines +.cometchat-message-header .cometchat-list-item__trailing-view .cometchat-button { + background: transparent; + height: 24px; + width: 24px; + padding: 0; } -.cometchat-message-header - .cometchat-list-item__trailing-view - .cometchat-button__icon { - background: black; +.cometchat-message-header .cometchat-list-item__trailing-view .cometchat-button__icon { + background: black; } ``` @@ -592,7 +619,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -622,21 +649,17 @@ function CustomAuxiliaryButtonView() { - -```css -.cometchat-message-header - .cometchat-message-header__auxiliary-view - .cometchat-button { - background: transparent; - height: 24px; - width: 24px; - padding: 0; + +```css lines +.cometchat-message-header .cometchat-message-header__auxiliary-view .cometchat-button { + background: transparent; + height: 24px; + width: 24px; + padding: 0; } -.cometchat-message-header - .cometchat-message-header__auxiliary-view - .cometchat-button__icon { - background: black; +.cometchat-message-header .cometchat-message-header__auxiliary-view .cometchat-button__icon { + background: black; } ``` @@ -650,7 +673,7 @@ The `lastActiveAtDateTimeFormat` property allows you to customize the **last act Default Date Time Format: -```ruby +```ruby lines new CalendarObject({ today: `[Last seen DD MMM at] hh:mm A`, // Example: "today at 10:30 AM" yesterday: `[Last seen DD MMM at] hh:mm A`, // Example: "yesterday at 08:15 PM" @@ -667,7 +690,7 @@ The following example demonstrates how to modify the **last active** timestamp f -```ts +```ts lines import { CometChatMessageHeader, CalendarObject, @@ -703,3 +726,36 @@ function getDateFormat() { *** + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| Typing indicator not showing | No active typing in the conversation | Typing indicator appears only when the other user is actively typing | +| Back button not visible | `hideBackButton={true}` is set | Remove or set `hideBackButton={false}` | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Render messages in a chat view + + + Compose and send messages + + + Display threaded message details + + + Display recent conversations + + diff --git a/ui-kit/react/message-list.mdx b/ui-kit/react/message-list.mdx index e2300b1d1..579889c3e 100644 --- a/ui-kit/react/message-list.mdx +++ b/ui-kit/react/message-list.mdx @@ -1,7 +1,36 @@ --- title: "Message List" +description: "CometChatMessageList component renders a scrollable list of sent and received messages including text, media, reactions, read receipts, and threaded replies. Supports custom message templates, date separators, and CSS styling." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatMessageList } from "@cometchat/chat-uikit-react"; + +// For a user chat + + +// For a group chat + +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatMessageList } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` or `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` +**Key props:** `user: CometChat.User`, `group: CometChat.Group`, `messagesRequestBuilder: CometChat.MessagesRequestBuilder`, `templates: CometChatMessageTemplate[]`, `hideReceipts: boolean` +**CSS class:** `.cometchat-message-list` +**Events:** `CometChatMessageEvents` + + ## Overview `MessageList` is a composite component that displays a list of messages and effectively manages real-time operations. It includes various types of messages such as Text Messages, Media Messages, Stickers, and more. @@ -10,6 +39,11 @@ title: "Message List" + + +**Before using this component:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + *** ## Usage @@ -19,8 +53,8 @@ title: "Message List" The following code snippet illustrates how you can directly incorporate the MessageList component into your Application. - -```tsx + +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -43,18 +77,25 @@ export function MessageListDemo() { - -```tsx -import { MessageListDemo } from "./MessageListDemo"; + +```jsx lines +import React, { useState, useEffect } from "react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatMessageList } from "@cometchat/chat-uikit-react"; -export default function App() { - return ( -
-
- -
+export function MessageListDemo() { + const [chatUser, setChatUser] = useState(null); + useEffect(() => { + CometChat.getUser("uid").then((user) => { + setChatUser(user); + }); + }, []); + + return chatUser ? ( +
+
- ); + ) : null; } ``` @@ -74,13 +115,13 @@ To fetch messages for a specific entity, you need to supplement it with `User` o [Actions](/ui-kit/react/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs. -##### 1. onThreadRepliesClick +#### 1. onThreadRepliesClick `onThreadRepliesClick` is triggered when you click on the threaded message bubble. The `onThreadRepliesClick` action doesn't have a predefined behavior. You can override this action using the following code snippet. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -111,7 +152,7 @@ export function MessageListDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -144,13 +185,13 @@ export function MessageListDemo() { -##### 2. onError +#### 2. onError This action doesn't change the behavior of the component but rather listens for any errors that occur in the MessageList component. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -178,7 +219,7 @@ export function MessageListDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -208,13 +249,13 @@ export function MessageListDemo() { -##### 3. onReactionClick +#### 3. onReactionClick `onReactionClick` is triggered when you click on the reaction item of the message bubble. The `onReactionClick` action doesn't have a predefined behavior. You can override this action using the following code snippet. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -245,7 +286,7 @@ export function MessageListDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -275,13 +316,13 @@ export function MessageListDemo() { -##### 4. onReactionListItemClick +#### 4. onReactionListItemClick `onReactionListItemClick` is triggered when you click on the reaction list item of the reaction list. The `onReactionListItemClick` action doesn't have a predefined behavior. You can override this action using the following code snippet. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -315,7 +356,7 @@ export function MessageListDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -350,7 +391,7 @@ export function MessageListDemo() { ### Filters -##### 1. Messages Request Builder +#### 1. Messages Request Builder You can adjust the `MessagesRequestBuilder` in the MessageList Component to customize your message list. Numerous options are available to alter the builder to meet your specific needs. For additional details on `MessagesRequestBuilder`, please visit [MessagesRequestBuilder](/sdk/javascript/additional-message-filtering). @@ -358,7 +399,7 @@ In the example below, we are applying a filter to the messages based on a search -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -387,7 +428,7 @@ export function MessageListDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -427,13 +468,13 @@ The following parameters in messageRequestBuilder will always be altered inside -##### 2. Reactions Request Builder +#### 2. Reactions Request Builder You can adjust the `ReactionsRequestBuilder` in the MessageList Component to customize and fetch the reactions for the messages. Numerous options are available to alter the builder to meet your specific needs. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -462,7 +503,7 @@ export function MessageListDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -512,7 +553,7 @@ Adding `CometChatMessageEvents` Listener's -```ts +```ts lines import { CometChatMessageEvents, CometChatUIEvents } from "@cometchat/chat-uikit-react"; const ccOpenChat = CometChatUIEvents.ccOpenChat.subscribe(() => { @@ -543,7 +584,7 @@ const ccMessageRead = CometChatMessageEvents.ccMessageRead.subscribe(() => { -```js +```js lines import { CometChatMessageEvents, CometChatUIEvents } from "@cometchat/chat-uikit-react"; const ccOpenChat = CometChatUIEvents.ccOpenChat.subscribe(() => { @@ -575,13 +616,11 @@ const ccMessageRead = CometChatMessageEvents.ccMessageRead.subscribe(() => { -*** - Removing `CometChatMessageEvents` Listener's -```ts +```ts lines ccMessageEdited?.unsubscribe(); ccReplyToMessage?.unsubscribe(); ccActiveChatChanged?.unsubscribe(); @@ -590,7 +629,7 @@ ccActiveChatChanged?.unsubscribe(); -```js +```js lines ccMessageEdited?.unsubscribe(); ccReplyToMessage?.unsubscribe(); ccActiveChatChanged?.unsubscribe(); @@ -618,7 +657,7 @@ You can set the css to the MessageList Component Component to customize the styl -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -628,8 +667,8 @@ import { CometChatMessageList } from "@cometchat/chat-uikit-react"; - -```css + +```css lines .cometchat-message-bubble__body .cometchat-text-bubble.cometchat-text-bubble-incoming .cometchat-text-bubble__body-text { @@ -647,7 +686,7 @@ These are a set of small functional customizations that allow you to fine-tune t -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -675,7 +714,7 @@ export function MessageListDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -762,7 +801,7 @@ You can set message Templates to MessageList by using the following code snippet -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -823,7 +862,7 @@ export function MessageListDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -886,7 +925,7 @@ The `separatorDateTimeFormat` property allows you to customize the **Date Separa Default Date Time Format: -```javascript +```javascript lines new CalendarObject({ today: "today" // Example: "today" yesterday: "yesterday", // Example: "yesterday" @@ -898,7 +937,7 @@ The following example demonstrates how to modify the **Date Separator** timestam -```ts +```ts lines import { CometChatMessageList, CalendarObject, @@ -943,7 +982,7 @@ The `stickyDateTimeFormat` property allows you to customize the **Sticky Date** Default Date Time Format: -```javascript +```javascript lines new CalendarObject({ today: "today" // Example: "today" yesterday: "yesterday", // Example: "yesterday" @@ -955,7 +994,7 @@ The following example demonstrates how to modify the **Sticky Date** timestamp f -```ts +```ts lines import { CometChatMessageList, CalendarObject, @@ -995,7 +1034,7 @@ The `messageSentAtDateTimeFormat` property allows you to customize the **Message Default Date Time Format: -```javascript +```javascript lines new CalendarObject({ today: "hh:mm A" // Example: "12:00 PM" yesterday: "hh:mm A", // Example: "01:00 AM" @@ -1007,7 +1046,7 @@ The following example demonstrates how to modify the **Message SentAt** timestam -```ts +```ts lines import { CometChatMessageList, CalendarObject, @@ -1050,7 +1089,7 @@ The `messageInfoDateTimeFormat` property allows you to customize the **Message I Default Date Time Format: -```ruby +```ruby lines new CalendarObject({ today: `DD MMM, hh:mm A`, // Example: "29 Jan, 04:34 AM" yesterday: `DD MMM, hh:mm A`, // Example: "29 Jan, 04:34 AM" @@ -1062,7 +1101,7 @@ The following example demonstrates how to modify the **Message Info** timestamp -```ts +```ts lines import { CometChatMessageList, CalendarObject, @@ -1113,7 +1152,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -1151,7 +1190,7 @@ export function MessageListDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -1188,8 +1227,8 @@ export function MessageListDemo() { - -```css + +```css lines .header-view { display: flex; width: 100%; @@ -1244,7 +1283,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -1284,7 +1323,7 @@ export function MessageListDemo() { -```js +```js lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -1323,8 +1362,8 @@ export function MessageListDemo() { - -```css + +```css lines .footer-view { display: flex; width: 100%; @@ -1371,7 +1410,7 @@ Assigns the list of text formatters. If the provided list is not null, it sets t -```ts +```ts lines import { CometChatTextFormatter } from "@cometchat/chat-uikit-react"; import DialogHelper from "./Dialog"; import { CometChat } from "@cometchat/chat-sdk-javascript"; @@ -1485,7 +1524,7 @@ export default ShortcutFormatter; -```tsx +```tsx lines import React from "react"; import ReactDOM from "react-dom"; @@ -1553,7 +1592,7 @@ export default class DialogHelper { -```tsx +```tsx lines import React from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatMessageList } from "@cometchat/chat-uikit-react"; @@ -1583,3 +1622,36 @@ export function MessageListDemo() { *** + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no messages | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| Messages not updating in real-time | WebSocket connection issue | Check [Connection Status](/sdk/javascript/connection-status) | +| Custom template not rendering | Template `type` or `category` doesn't match message | Verify template matches the message's `type` and `category` fields | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Compose and send messages + + + Display user/group details in the toolbar + + + Customize message bubble rendering + + + Display threaded message details + + diff --git a/ui-kit/react/message-template.mdx b/ui-kit/react/message-template.mdx index 7659b7286..7852cea55 100644 --- a/ui-kit/react/message-template.mdx +++ b/ui-kit/react/message-template.mdx @@ -1,9 +1,41 @@ --- title: "Message Template" +description: "CometChatMessageTemplate provides a structure for defining custom message types and their rendering in the message list. Use templates to customize how different message categories and types are displayed." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChatMessageTemplate } from "@cometchat/chat-uikit-react"; +import { ChatConfigurator } from "@cometchat/chat-uikit-react"; + +// Get default templates +const templates = ChatConfigurator.getDataSource().getAllMessageTemplates(); + +// Pass custom templates to MessageList + +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatMessageTemplate } from "@cometchat/chat-uikit-react";` +**Usage:** Pass `templates` prop to `CometChatMessageList` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` +**Key properties:** `category: string`, `type: string`, `contentView`, `bubbleView`, `headerView`, `footerView` +**Related:** Used with `CometChatMessageList` via the `templates` prop + + ## Overview + +**Before using message templates:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + MessageTemplate provides you with the capability to define and customize both the structure and the behavior of the Message Bubble. It acts as a schema or design blueprint for the creation of a variety of Message Bubble components, allowing you to manage the appearance and interactions of Message Bubble within your application effectively and consistently. ### Structure @@ -96,7 +128,7 @@ You will need to first get the MessageTemplate object for the type of message yo -```ts +```ts lines import { CometChatUIKit, CometChatUIKitConstants, @@ -114,7 +146,7 @@ for (let i = 0; i < allTemplates.length; i++) { -```js +```js lines import { CometChatUIKit, CometChatUIKitConstants, @@ -136,7 +168,7 @@ You will be using [Message List](/ui-kit/react/message-list) component using the -```ts +```ts lines import { CometChatMessageList } from "@cometchat/uikit-react"; ; @@ -145,7 +177,7 @@ import { CometChatMessageList } from "@cometchat/uikit-react"; -```js +```js lines import { CometChatMessageList } from "@cometchat/uikit-react"; ; @@ -165,7 +197,7 @@ The `headerView` method of MessageTemplate allows you to add custom views to the -```ts +```ts lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, @@ -220,7 +252,7 @@ export { CustomMessageTemplate }; -```js +```js lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, @@ -284,7 +316,7 @@ The `contentview` method of MessageTemplate allows you to add a custom view to t -```ts +```ts lines import React from "react"; import { CometChatMessageList, @@ -382,7 +414,7 @@ export { CustomMessageTemplate }; -```js +```js lines import React from "react"; import { CometChatMessageList, @@ -477,8 +509,8 @@ export { CustomMessageTemplate }; - -```css + +```css lines .content-view__header-banner { border-radius: 12px; } @@ -547,7 +579,7 @@ The `bottomView` method of MessageTemplate allows you to add a custom button vie -```ts +```ts lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, @@ -607,7 +639,7 @@ export { CustomMessageTemplate }; -```js +```js lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, CometChatUIKit, CometChatUIKitConstants } from '@cometchat/chat-uikit-react'; import { CometChat } from "@cometchat/chat-sdk-javascript"; @@ -655,8 +687,8 @@ export { CustomMessageTemplate }; - -```css + +```css lines .cometchat .cometchat-message-bubble__body { border-radius: 12px 12px 0px 0px; } @@ -707,7 +739,7 @@ The `footerView` method of MessageTemplate allows you to add a footer view to yo -```ts +```ts lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, @@ -770,7 +802,7 @@ export { CustomMessageTemplate }; -```js +```js lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, @@ -830,8 +862,8 @@ export { CustomMessageTemplate }; - -```css + +```css lines .cometchat .cometchat-message-bubble__body-footer-view { display: flex; align-items: center; @@ -863,7 +895,7 @@ The `bubbleView` method of MessageTemplate allows you to add a bubble view to yo -```ts +```ts lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, @@ -978,7 +1010,7 @@ export { CustomMessageTemplate }; -```js +```js lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, CometChatUIKit, CometChatUIKitConstants,CometChatMessageTemplate,Receipts,MessageBubbleAlignment,CometChatUIKitLoginListener,MessageReceiptUtils, isMessageSentByMe } from '@cometchat/chat-uikit-react'; import { CometChat } from "@cometchat/chat-sdk-javascript"; @@ -1079,8 +1111,8 @@ export { CustomMessageTemplate }; - -```css + +```css lines .bubble-view { display: flex; flex-direction: column; @@ -1168,7 +1200,7 @@ The `statusInfoView` method of MessageTemplate allows you to add a status info v -```ts +```ts lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, @@ -1239,7 +1271,7 @@ export { CustomMessageTemplate }; -```js +```js lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, CometChatUIKit, CometChatUIKitConstants } from '@cometchat/chat-uikit-react'; import { CometChat } from "@cometchat/chat-sdk-javascript"; @@ -1304,8 +1336,8 @@ export { CustomMessageTemplate }; - -```css + +```css lines .status-info { display: flex; width: 57px; @@ -1349,7 +1381,7 @@ The `replyView` method of MessageTemplate allows you to add a reply view to your -```ts +```ts lines import React, { useEffect, useState } from "react"; import { CometChatMessageList @@ -1380,7 +1412,7 @@ export { CustomMessageTemplate }; -```js +```js lines import React, { useEffect, useState } from "react"; import { CometChatMessageList } from '@cometchat/chat-uikit-react'; import { CometChat } from "@cometchat/chat-sdk-javascript"; @@ -1406,8 +1438,8 @@ export { CustomMessageTemplate }; - -```css + +```css lines .cometchat .cometchat-message-bubble-outgoing .cometchat-message-bubble__body { @@ -1440,7 +1472,7 @@ However, if you wish to override or modify these options, you can use the `optio -```ts +```ts lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, @@ -1519,7 +1551,7 @@ export { CustomMessageTemplate }; -```js +```js lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, @@ -1586,8 +1618,8 @@ export { CustomMessageTemplate }; - -```css + +```css lines #refresh.cometchat-menu-list__menu .cometchat-menu-list__sub-menu-item-title { overflow: hidden; color: #6852d6; @@ -1615,7 +1647,7 @@ You can create an entirely new template for custom messages is one of the powerf -```ts +```ts lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, @@ -1742,7 +1774,7 @@ export { CustomMessageTemplate }; -```js +```js lines import React, { useEffect, useState } from "react"; import { CometChatMessageList, CometChatUIKit, CometChatUIKitConstants, CometChatMessageTemplate,MessageReceiptUtils,isMessageSentByMe,Receipts,CometChatUIKitLoginListener } from '@cometchat/chat-uikit-react'; @@ -1852,8 +1884,8 @@ export { CustomMessageTemplate }; - -```css + +```css lines .content-view { display: flex; flex-direction: column; @@ -1933,3 +1965,37 @@ export { CustomMessageTemplate }; + + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Custom template not rendering | Template `type` or `category` doesn't match message | Verify template matches the message's `type` and `category` fields | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Default templates missing | Not using `ChatConfigurator.getDataSource().getAllMessageTemplates()` | Start with default templates and modify from there | +| Custom view returning blank | View function returns `null` or `undefined` | Ensure view function returns valid JSX | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Use templates with the message list component + + + Compose and send messages + + + Customize the look and feel of your chat UI + + + Style individual message bubbles with CSS + + diff --git a/ui-kit/react/methods.mdx b/ui-kit/react/methods.mdx index 0be19fef4..698b18337 100644 --- a/ui-kit/react/methods.mdx +++ b/ui-kit/react/methods.mdx @@ -1,7 +1,18 @@ --- title: "Methods" +description: "Reference for CometChat React UI Kit methods including init, login, logout, and message-sending wrappers." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Import:** `import { CometChatUIKit } from "@cometchat/chat-uikit-react";` +- **Init:** `CometChatUIKit.init(UIKitSettings)` +- **Login (dev):** `CometChatUIKit.login("UID")` | **Login (prod):** `CometChatUIKit.loginWithAuthToken("AUTH_TOKEN")` +- **Other methods:** `CometChatUIKit.logout()`, `CometChatUIKit.getLoggedinUser()`, `CometChatUIKit.createUser(user)` +- **Send messages:** `CometChatUIKit.sendTextMessage()`, `CometChatUIKit.sendMediaMessage()`, `CometChatUIKit.sendCustomMessage()` +- **Note:** Use these wrapper methods instead of raw SDK calls — they manage internal UI Kit eventing + + ## Overview The UI Kit's core function is to extend the [Chat SDK](/sdk/javascript/overview), essentially translating the raw data and functionality provided by the underlying methods into visually appealing and easy-to-use UI components. @@ -10,6 +21,14 @@ To effectively manage and synchronize the UI elements and data across all compon The CometChat UI Kit has thoughtfully encapsulated the critical [Chat SDK](/sdk/javascript/overview) methods within its wrapper to efficiently manage internal eventing. This layer of abstraction simplifies interaction with the underlying CometChat SDK, making it more user-friendly for developers. + +You must call `CometChatUIKit.init(UIKitSettings)` before rendering any UI Kit components or calling any SDK methods. Initialization must complete before login. + + + +**Auth Key** is for development/testing only. In production, generate **Auth Tokens** on your server using the REST API and pass them to the client. Never expose Auth Keys in production client code. + + ## Methods You can access the methods using the `CometChatUIKit` class. This class provides access to all the public methods exposed by the CometChat UI Kit. @@ -26,7 +45,7 @@ Make sure you replace the **APP\_ID**, **REGION** and **AUTH\_KEY** with your Co -```js +```js lines highlight={4-6} import { UIKitSettingsBuilder } from "@cometchat/uikit-shared"; //import shared package const COMETCHAT_CONSTANTS = { @@ -61,7 +80,7 @@ If you want to use session storage instead of the default local storage, you can -```js +```js lines highlight={5-7} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { UIKitSettingsBuilder } from "@cometchat/chat-uikit-react"; @@ -89,7 +108,7 @@ CometChatUIKit.init(UIKitSettings)?.then(() => { -```ts +```ts lines highlight={5-7} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { UIKitSettingsBuilder } from "@cometchat/chat-uikit-react"; @@ -123,7 +142,7 @@ You can use this method to check if there is any existing session in the SDK. Th -```js +```js lines import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package CometChatUIKit.getLoggedinUser() @@ -145,7 +164,7 @@ This simple authentication procedure is useful when you are creating a POC or if -```js +```js lines highlight={3} import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package const UID = "UID"; @@ -170,7 +189,7 @@ CometChatUIKit.getLoggedinUser() -```ts +```ts lines highlight={3} import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package const UID: string = "UID"; @@ -208,7 +227,7 @@ This advanced authentication procedure does not use the Auth Key directly in you -```js +```js lines highlight={3} import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package const authToken = "AUTH_TOKEN"; @@ -234,7 +253,7 @@ CometChatUIKit.getLoggedinUser() -```ts +```ts lines highlight={3} import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package const authToken: string = "AUTH_TOKEN"; @@ -266,7 +285,7 @@ This method is used to end the user session of the logged-in user -```js +```js lines import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package CometChatUIKit.logout(); @@ -284,7 +303,7 @@ This method takes a `User` object and the `Auth Key` as input parameters and ret -```js +```js lines highlight={4-6} import { CometChat } from "@cometchat/chat-sdk-javascript"; //import sdk package import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package @@ -311,7 +330,7 @@ CometChatUIKit.createUser(user, authKey) -```ts +```ts lines highlight={4-6} import { CometChat } from "@cometchat/chat-sdk-javascript"; //import sdk package import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package @@ -347,7 +366,7 @@ This method takes a `User` object and the `Auth Key` as inputs and returns the u -```js +```js lines highlight={4-6} import { CometChat } from "@cometchat/chat-sdk-javascript"; //import sdk package import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package @@ -367,7 +386,7 @@ CometChatUIKit.updateUser(user, authKey) -```ts +```ts lines highlight={4-6} import { CometChat } from "@cometchat/chat-sdk-javascript"; //import sdk package import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package @@ -398,7 +417,7 @@ This method sends a text message in a 1:1 or group chat. You need to pass a `Tex -```tsx +```tsx lines highlight={5-6} import { CometChat } from "@cometchat/chat-sdk-javascript"; //import sdk package import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package import { CometChatUIKitConstants } from "@cometchat/uikit-resources"; //import shared package @@ -422,7 +441,7 @@ CometChatUIKit.sendTextMessage(textMessage) -```tsx +```tsx lines highlight={5-6} import { CometChat } from "@cometchat/chat-sdk-javascript"; //import sdk package import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package import { CometChatUIKitConstants } from "@cometchat/uikit-resources"; //import shared package @@ -461,7 +480,7 @@ Make sure you replace the `INPUT FILE OBJECT` with the actual [file](https://dev -```tsx +```tsx lines highlight={5} import { CometChat } from "@cometchat/chat-sdk-javascript"; //import sdk package import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package import { CometChatUIKitConstants } from "@cometchat/uikit-resources"; //import shared package @@ -486,7 +505,7 @@ CometChatUIKit.sendMediaMessage(mediaMessage) -```tsx +```tsx lines highlight={5} import { CometChat } from "@cometchat/chat-sdk-javascript"; //import sdk package import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package import { CometChatUIKitConstants } from "@cometchat/uikit-resources"; //import shared package @@ -520,7 +539,7 @@ This method allows you to send custom messages which are neither text nor media -```tsx +```tsx lines highlight={5,7,8} import { CometChat } from "@cometchat/chat-sdk-javascript"; //import sdk package import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package import { CometChatUIKitConstants } from "@cometchat/uikit-resources"; //import shared package @@ -549,7 +568,7 @@ CometChatUIKit.sendCustomMessage(customMessage) -```tsx +```tsx lines highlight={5,7,8} import { CometChat } from "@cometchat/chat-sdk-javascript"; //import sdk package import { CometChatUIKit } from "@cometchat/chat-uikit-react"; //import uikit package import { CometChatUIKitConstants } from "@cometchat/uikit-resources"; //import shared package @@ -578,3 +597,42 @@ CometChatUIKit.sendCustomMessage(customMessage) + +*** + +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| `init()` fails silently | Invalid App ID, Region, or Auth Key | Double-check credentials from the [CometChat Dashboard](https://app.cometchat.com/) | +| `login()` returns error | UID doesn’t exist or Auth Key is invalid | Create the user first via Dashboard or `createUser()` method | +| `getLoggedinUser()` returns null | User not logged in or session expired | Call `login()` or `loginWithAuthToken()` first | +| `sendTextMessage()` fails | User not logged in or invalid receiver | Ensure login completes before sending messages | +| Auth Key exposed in production | Using Auth Key instead of Auth Token | Switch to `loginWithAuthToken()` for production | + + + + +*** + +## Next Steps + + + + Subscribe to real-time events across UI Kit components. + + + Explore all available prebuilt UI components. + + + Customize colors, fonts, and styles. + + + Learn about messaging, real-time updates, and more. + + + +*** diff --git a/ui-kit/react/next-conversation.mdx b/ui-kit/react/next-conversation.mdx index 1d8800f66..824fa8712 100644 --- a/ui-kit/react/next-conversation.mdx +++ b/ui-kit/react/next-conversation.mdx @@ -1,8 +1,18 @@ --- title: "Building A Conversation List + Message View" sidebarTitle: "Conversation List + Message View" +description: "Build a two-panel conversation list + message view layout in Next.js with CometChat UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Framework:** Next.js +- **Key components:** `CometChatConversations` + `CometChatMessageList` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Parent guide:** [Next.js Integration](/ui-kit/react/next-js-integration) + + + The **Conversation List + Message View** layout offers a seamless **two-panel chat interface**, commonly used in modern messaging applications like **WhatsApp Web, Slack, and Microsoft Teams**. This design enables users to switch between conversations effortlessly while keeping the chat window open, ensuring a **smooth, real-time messaging experience**. @@ -52,7 +62,7 @@ These icons are available in the **CometChat UI Kit assets folder**. You can fin -```tsx CometChatSelector.tsx +```tsx CometChatSelector.tsx lines import { useEffect, useState } from "react"; import { Conversation, Group, User } from "@cometchat/chat-sdk-javascript"; import { CometChatConversations, CometChatUIKitLoginListener } from "@cometchat/chat-uikit-react"; @@ -107,7 +117,7 @@ export const CometChatSelector = (props: SelectorProps) => { -```css CometChatSelector.css +```css CometChatSelector.css lines /* Style for the icon in the header menu of the conversation list */ .selector-wrapper .cometchat-conversations .cometchat-list__header-menu .cometchat-button__icon { background: var(--cometchat-icon-color-primary); @@ -192,7 +202,7 @@ src/ -```tsx CometChatNoSSR.tsx +```tsx CometChatNoSSR.tsx lines highlight={15-17, 20} import React, { useEffect, useState } from "react"; import { CometChatMessageComposer, @@ -212,6 +222,8 @@ const COMETCHAT_CONSTANTS = { AUTH_KEY: "", }; +const UID = "cometchat-uid-1"; // Replace with your actual UID + // Functional Component const CometChatNoSSR: React.FC = () => { // State to store the logged-in user @@ -237,7 +249,7 @@ const CometChatNoSSR: React.FC = () => { CometChatUIKit.getLoggedinUser().then((loggedInUser) => { if (!loggedInUser) { // Perform login if no user is logged in - CometChatUIKit.login("cometchat-uid-1") + CometChatUIKit.login(UID) .then((user) => { console.log("Login Successful", { user }); setUser(user); @@ -299,7 +311,7 @@ export default CometChatNoSSR; -```css CometChatNoSSR.css +```css CometChatNoSSR.css lines /* Layout for the main conversations and messages container */ .conversations-with-messages { display: flex; @@ -360,7 +372,7 @@ In this update, we will **disable Server-Side Rendering (SSR) for `CometChatNoSS Modify your `index.tsx` file to dynamically import the `CometChatNoSSR.tsx` component with `{ ssr: false }`. -```tsx index.tsx +```tsx index.tsx lines import { Inter } from "next/font/google"; import dynamic from "next/dynamic"; @@ -388,7 +400,7 @@ export default function Home() { Next, add the following styles to global.css to ensure CometChat UI Kit is properly styled. -```css global.css +```css global.css lines :root { --background: #ffffff; --foreground: #171717; @@ -449,16 +461,62 @@ a { ### **Step 5: Run the project** -``` + + +```bash lines npm run dev ``` + + + +```bash lines +pnpm dev +``` + + + +```bash lines +yarn dev +``` + + *** -## **Next Steps** -### **Enhance the User Experience** +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn’t render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| CSS/theme not applied | Missing CSS import | Add `@import url("@cometchat/chat-uikit-react/css-variables.css");` in your CSS | +| Blank screen after login | Component mounted before init/login completes | Use state to conditionally render after login resolves | +| Messages not loading | Invalid user/group object passed | Ensure you fetch the user/group via SDK before passing to components | + + + + +*** + +## **Next Steps** -* **[Advanced Customizations](/ui-kit/react/theme)** – Personalize the chat UI to align with your brand. + + + Personalize the chat UI to align with your brand. + + + Explore all available prebuilt UI components. + + + Return to the Next.js setup guide. + + + Learn about messaging, real-time updates, and more. + + *** diff --git a/ui-kit/react/next-js-integration.mdx b/ui-kit/react/next-js-integration.mdx index 0d4c40aac..d103a2161 100644 --- a/ui-kit/react/next-js-integration.mdx +++ b/ui-kit/react/next-js-integration.mdx @@ -1,10 +1,24 @@ --- title: "Getting Started With CometChat React UI Kit For Next.js" sidebarTitle: "Integration" +description: "Step-by-step guide to integrate CometChat React UI Kit into your Next.js application with App Router support." --- + +- **Package:** `@cometchat/chat-uikit-react` — `npm install @cometchat/chat-uikit-react` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` — must complete before rendering +- **SSR:** CometChat requires browser APIs — use `'use client'` directive or dynamic imports with `ssr: false` +- **Init code:** `new UIKitSettingsBuilder().setAppId("APP_ID").setRegion("REGION").setAuthKey("AUTH_KEY").build()` +- **Framework:** Next.js (this page) | [React.js](/ui-kit/react/react-js-integration) | [React Router](/ui-kit/react/react-router-integration) | [Astro](/ui-kit/react/astro-integration) +- **All components:** [Components Overview](/ui-kit/react/components-overview) + + The **CometChat UI Kit for React** streamlines the integration of in-app chat functionality by providing a **comprehensive set of prebuilt UI components**. It offers seamless **theming options**, including **light and dark modes**, customizable fonts, colors, and extensive styling capabilities. + +**Server-Side Rendering (SSR):** CometChat UI Kit requires browser APIs (`window`, `WebSocket`, `document`). For Next.js, ensure components render only on the client side using `'use client'` directive or dynamic imports with `ssr: false`. + + With built-in support for **one-to-one and group conversations**, developers can efficiently enable chat features within their applications. Follow this guide to **quickly integrate chat functionality** using the CometChat React UI Kit. {/* @@ -132,7 +146,7 @@ Before using any features of the **CometChat UI Kit** or **CometChat SDK**, you -```ts +```ts lines highlight={7-9} import { CometChatUIKit, UIKitSettingsBuilder } from "@cometchat/chat-uikit-react"; /** @@ -172,7 +186,7 @@ CometChatUIKit.init(UIKitSettings)! -```js +```js lines highlight={7-9} import { CometChatUIKit, UIKitSettingsBuilder } from "@cometchat/chat-uikit-react"; /** @@ -250,7 +264,7 @@ The **Login** method returns a **User object** containing all relevant details o -```ts +```ts lines highlight={3} import { CometChatUIKit } from "@cometchat/chat-uikit-react"; const UID = "UID"; // Replace with your actual UID @@ -273,7 +287,7 @@ CometChatUIKit.getLoggedinUser().then((user: CometChat.User | null) => { -```js +```js lines highlight={3} import { CometChatUIKit } from "@cometchat/chat-uikit-react"; const UID = "UID"; // Replace with your actual UID @@ -422,13 +436,44 @@ Integrate a conversation view that suits your application's **UX requirements**. *** +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| `CometChatUIKit.init()` fails silently | Invalid App ID, Region, or Auth Key | Double-check credentials from the [CometChat Dashboard](https://app.cometchat.com/) | +| Component doesn’t render | `init()` not called or not awaited before rendering | Ensure `init()` completes before mounting components. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| Login fails with "UID not found" | UID doesn’t exist in your CometChat app | Create the user via Dashboard, SDK, or API first | +| CSS/theme not applied | Missing CSS import | Add `@import url("@cometchat/chat-uikit-react/css-variables.css");` in your `App.css` | +| Blank screen after login | Component mounted before init/login completes | Use state to conditionally render after login resolves | +| SSR hydration error | CometChat components use browser APIs on server | Wrap in `useEffect` or use dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | +| Auth Key exposed in production | Using Auth Key instead of Auth Token | Switch to [Auth Token](/ui-kit/react/methods#login-using-auth-token) for production | + + + + +*** + ## **Next Steps** Now that you’ve selected your **chat experience**, proceed to the **integration guide**: -* **[Integrate Conversation List + Message](/ui-kit/react/next-conversation)** -* **[Integrate One-to-One Chat](/ui-kit/react/next-one-to-one-chat)** -* **[Integrate Tab-Based Chat](/ui-kit/react/next-tab-based-chat)** -* **[Advanced Customizations](/ui-kit/react/theme)** + + + Two-panel layout with conversation list and message view. + + + Focused direct messaging experience without a sidebar. + + + Multi-tab navigation for chats, calls, users, and settings. + + + Customize colors, fonts, and styles to match your branding. + + *** diff --git a/ui-kit/react/next-one-to-one-chat.mdx b/ui-kit/react/next-one-to-one-chat.mdx index 6b9ca33f4..97884527e 100644 --- a/ui-kit/react/next-one-to-one-chat.mdx +++ b/ui-kit/react/next-one-to-one-chat.mdx @@ -1,8 +1,18 @@ --- title: "Building A One To One/Group Chat Experience" sidebarTitle: "One To One/Group Chat" +description: "Build a focused one-to-one or group chat experience in Next.js with CometChat UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Framework:** Next.js +- **Key components:** `CometChatMessageHeader` + `CometChatMessageList` + `CometChatMessageComposer` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Parent guide:** [Next.js Integration](/ui-kit/react/next-js-integration) + + + The **One-to-One Chat** feature provides a streamlined **direct messaging interface**, making it ideal for **support chats, dating apps, and private messaging platforms**. This setup eliminates distractions by focusing solely on a **dedicated chat window**. [](https://link.cometchat.com/next-one-on-one) @@ -70,7 +80,7 @@ src/ -```tsx CometChatNoSSR.tsx +```tsx CometChatNoSSR.tsx lines highlight={7-9, 31, 51, 61} import React, { useEffect, useState } from "react"; import { CometChatMessageComposer, CometChatMessageHeader, CometChatMessageList, CometChatUIKit, UIKitSettingsBuilder } from "@cometchat/chat-uikit-react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; @@ -101,7 +111,7 @@ const CometChatNoSSR: React.FC = () => { console.log("Initialization completed successfully"); CometChatUIKit.getLoggedinUser().then((loggedInUser) => { if (!loggedInUser) { - CometChatUIKit.login("superhero1") + CometChatUIKit.login("cometchat-uid-2") //TODO: Replace with your actual UID .then((user) => { console.log("Login Successful", { user }); setUser(user); @@ -164,7 +174,7 @@ export default CometChatNoSSR; -```css CometChatNoSSR.css +```css CometChatNoSSR.css lines .messages-wrapper { width: 100%; height: 100%; @@ -196,8 +206,9 @@ In the code snippet above, ensure you select either a user or a group based on y #### **Fetching a User (One-on-One Chat)** -```javascript +```javascript lines highlight={1} const UID = "cometchat-uid-1"; + CometChat.getUser(UID).then( user => { setSelectedUser(user); @@ -209,8 +220,9 @@ CometChat.getUser(UID).then( #### **Fetching a Group (Group Chat)** -```javascript +```javascript lines highlight={1} const GUID = "GUID" + CometChat.getGroup(GUID).then( group => { setSelectedGroup(group); @@ -228,7 +240,7 @@ In this update, we will **disable Server-Side Rendering (SSR) for `CometChatNoSS Modify your `index.tsx` file to dynamically import the `CometChatNoSSR.tsx` component with `{ ssr: false }`. -```tsx index.tsx +```tsx index.tsx lines import { Inter } from "next/font/google"; import dynamic from "next/dynamic"; @@ -258,7 +270,7 @@ export default function Home() { Next, add the following styles to global.css to ensure CometChat UI Kit is properly styled. -```css global.css +```css global.css lines :root { --background: #ffffff; --foreground: #171717; @@ -321,14 +333,60 @@ a { ### **Step 6: Run the project** -``` + + +```bash lines npm run dev ``` + -## **Next Steps** + +```bash lines +pnpm dev +``` + + + +```bash lines +yarn dev +``` + + + + +## Common Failure Modes + + + -### **Enhance the User Experience** +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn’t render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| CSS/theme not applied | Missing CSS import | Add `@import url("@cometchat/chat-uikit-react/css-variables.css");` in your CSS | +| Blank screen after login | Component mounted before init/login completes | Use state to conditionally render after login resolves | +| Messages not loading | Invalid user/group object passed | Ensure you fetch the user/group via SDK before passing to components | + + + + +*** + +## **Next Steps** -* **[Advanced Customizations](/ui-kit/react/theme)** – Personalize the chat UI to align with your brand. + + + Personalize the chat UI to align with your brand. + + + Explore all available prebuilt UI components. + + + Return to the Next.js setup guide. + + + Learn about messaging, real-time updates, and more. + + *** diff --git a/ui-kit/react/next-tab-based-chat.mdx b/ui-kit/react/next-tab-based-chat.mdx index 91f61a656..e739c9607 100644 --- a/ui-kit/react/next-tab-based-chat.mdx +++ b/ui-kit/react/next-tab-based-chat.mdx @@ -1,8 +1,18 @@ --- title: "Building A Messaging UI With Tabs, Sidebar, And Message View" sidebarTitle: "Tab Based Chat Experience" +description: "Build a tab-based messaging UI with chats, calls, users, and groups in Next.js with CometChat UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Framework:** Next.js +- **Key components:** `CometChatConversations` + `CometChatCallLogs` + `CometChatUsers` + `CometChatGroups` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Parent guide:** [Next.js Integration](/ui-kit/react/next-js-integration) + + + This guide walks you through creating a **tab-based messaging UI** using **React** and **CometChat UIKit**. The UI will include different sections for **Chats, Calls, Users, and Groups**, allowing seamless navigation. [](https://link.cometchat.com/next-tabs-sidebar-message) @@ -60,7 +70,7 @@ These icons are available in the **CometChat UI Kit assets folder**. You can fin -```tsx CometChatTabs.tsx +```tsx CometChatTabs.tsx lines import { useState } from "react"; import "./CometChatTabs.css"; @@ -145,7 +155,7 @@ export const CometChatTabs = (props: { -```css CometChatTabs.css +```css CometChatTabs.css lines /* Main container for the CometChat tab bar */ .cometchat-tab-component { display: flex; /* Align child tabs horizontally */ @@ -230,7 +240,7 @@ src/ -```tsx CometChatSelector.tsx +```tsx CometChatSelector.tsx lines import { useEffect, useState } from "react"; import { Call, @@ -352,7 +362,7 @@ export const CometChatSelector = (props: SelectorProps) => { -```css CometChatSelector.css +```css CometChatSelector.css lines /* Style the icon inside header menu in conversation list */ .selector-wrapper .cometchat-conversations .cometchat-list__header-menu .cometchat-button__icon { background: var(--cometchat-icon-color-primary); /* Primary icon color */ @@ -430,7 +440,7 @@ Now we will update the `CometChatNoSSR.tsx` & `CometChatNoSSR.css` files to impo -```tsx CometChatNoSSR.tsx +```tsx CometChatNoSSR.tsx lines highlight={15-17, 45} import React, { useEffect, useState } from "react"; import { CometChatMessageComposer, @@ -475,7 +485,7 @@ const CometChatNoSSR: React.FC = () => { CometChatUIKit.getLoggedinUser().then((loggedInUser) => { if (!loggedInUser) { // Perform login if no user is logged in - CometChatUIKit.login("cometchat-uid-4") + CometChatUIKit.login("cometchat-uid-4") //TODO: Replace with dynamic UID as needed .then((user) => { console.log("Login Successful", { user }); setUser(user); @@ -537,7 +547,7 @@ export default CometChatNoSSR; -```css CometChatNoSSR.css +```css CometChatNoSSR.css lines /* Layout for the main container that holds conversations and messages */ .conversations-with-messages { display: flex; @@ -598,7 +608,7 @@ In this update, we will **disable Server-Side Rendering (SSR) for `CometChatNoSS Modify your `index.tsx` file to dynamically import the `CometChatNoSSR.tsx` component with `{ ssr: false }`. -```tsx index.tsx +```tsx index.tsx lines import { Inter } from "next/font/google"; import dynamic from "next/dynamic"; @@ -626,7 +636,7 @@ export default function Home() { Next, add the following styles to global.css to ensure CometChat UI Kit is properly styled. -```css global.css +```css global.css lines :root { --background: #ffffff; --foreground: #171717; @@ -687,16 +697,62 @@ a { ### **Step 6: Run the project** -``` + + +```bash lines npm run dev ``` + + + +```bash lines +pnpm dev +``` + + + +```bash lines +yarn dev +``` + + *** -## **Next Steps** -### **Enhance the User Experience** +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn’t render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| CSS/theme not applied | Missing CSS import | Add `@import url("@cometchat/chat-uikit-react/css-variables.css");` in your CSS | +| Blank screen after login | Component mounted before init/login completes | Use state to conditionally render after login resolves | +| Messages not loading | Invalid user/group object passed | Ensure you fetch the user/group via SDK before passing to components | + + + + +*** + +## **Next Steps** -* **[Advanced Customizations](/ui-kit/react/theme)** – Personalize the chat UI to align with your brand. + + + Personalize the chat UI to align with your brand. + + + Explore all available prebuilt UI components. + + + Return to the Next.js setup guide. + + + Learn about messaging, real-time updates, and more. + + *** diff --git a/ui-kit/react/outgoing-call.mdx b/ui-kit/react/outgoing-call.mdx index 89413847a..f821feebb 100644 --- a/ui-kit/react/outgoing-call.mdx +++ b/ui-kit/react/outgoing-call.mdx @@ -1,9 +1,43 @@ --- title: "Outgoing Call" +description: "Display and manage outgoing voice and video calls with cancel controls using the CometChatOutgoingCall component." --- +{/* TL;DR for Agents and Quick Reference */} + +**Quick Reference for AI Agents & Developers** + +```tsx +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { CometChatOutgoingCall, CometChatUIKitConstants } from "@cometchat/chat-uikit-react"; + +// Requires a CometChat.Call object +const callObject = new CometChat.Call("uid", CometChatUIKitConstants.MessageTypes.audio, CometChatUIKitConstants.MessageReceiverType.user); +const initiatedCall = await CometChat.initiateCall(callObject); + + console.log("Call canceled")} + disableSoundForCalls={false} +/> +``` + + + +**AI Agent Component Spec** + +**Package:** `@cometchat/chat-uikit-react` +**Import:** `import { CometChatOutgoingCall } from "@cometchat/chat-uikit-react";` +**Minimal JSX:** `` +**Required setup:** `CometChatUIKit.init()` + `CometChatUIKit.login()` + `CometChat.initiateCall()` +**Key props:** `call` (CometChat.Call, required), `onCallCanceled` (callback), `disableSoundForCalls` (boolean), `titleView` (JSX), `subtitleView` (JSX) +**CSS class:** `.cometchat-outgoing-call` +**Events:** none emitted directly + + ## Overview + The outgoing call component is a visual representation of a user-initiated call, whether it's a voice or video call. It serves as an interface for managing outgoing calls, providing users with essential options to control the call experience. This component typically includes information about the call recipient, call controls for canceling the call, and feedback on the call status, such as indicating when the call is in progress. @@ -17,13 +51,18 @@ The `Outgoing Call` is comprised of the following components: | CometChat Button | This component represents a button with optional icon and text. | | CometChat Avatar | This component component displays an image or user's avatar with fallback to the first two letters of the username. | + + +**Before using this component:** Ensure `CometChatUIKit.init(UIKitSettings)` has completed and the user is logged in via `CometChatUIKit.login("UID")`. See [React.js Integration](/ui-kit/react/react-js-integration). + + ## Usage ### Integration - -```tsx + +```tsx lines highlight={12} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatOutgoingCall, @@ -35,7 +74,7 @@ const OutgoingCallDemo = () => { const [call, setCall] = React.useState(); React.useEffect(() => { - const uid = "uid"; + const uid = "uid"; //TODO: replace with actual UID of the call receiver const callObject = new CometChat.Call( uid, @@ -57,19 +96,37 @@ export default OutgoingCallDemo; - -```tsx -import { OutgoingCallDemo } from "./OutgoingCallDemo"; + +```jsx lines highlight={12} +import React, { useState, useEffect } from "react"; +import { CometChat } from "@cometchat/chat-sdk-javascript"; +import { + CometChatOutgoingCall, + CometChatUIKitConstants, +} from "@cometchat/chat-uikit-react"; -export default function App() { - return ( -
-
- -
-
- ); -} +const OutgoingCallDemo = () => { + const [call, setCall] = useState(null); + + useEffect(() => { + const uid = "uid"; + + const callObject = new CometChat.Call( + uid, + CometChatUIKitConstants.MessageTypes.audio, + CometChatUIKitConstants.MessageReceiverType.user + ); + CometChat.initiateCall(callObject) + .then((c) => { + setCall(c); + }) + .catch(console.log); + }, []); + + return call ? : null; +}; + +export default OutgoingCallDemo; ```
@@ -80,13 +137,13 @@ export default function App() { [Actions](/ui-kit/react/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs. -##### 1. onCallCanceled +#### 1. onCallCanceled The `onCallCanceled` event gets activated when the cancel button is clicked. It does not have a default behavior. However, you can override its behavior using the following code snippet. -```ts +```ts lines highlight={12} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatOutgoingCall, @@ -129,7 +186,7 @@ export default OutgoingCallDemo; -```js +```js lines highlight={9} import React, { useState, useEffect } from 'react'; import { CometChat } from '@cometchat/chat-sdk-javascript'; import { CometChatOutgoingCall, CometChatUIKitConstants } from '@cometchat/chat-uikit-react'; @@ -174,13 +231,13 @@ export default OutgoingCallDemo; -##### 2. onError +#### 2. onError This action doesn't change the behavior of the component but rather listens for any errors that occur in the Outgoing Call component. -```ts +```ts lines highlight={12} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatOutgoingCall, @@ -222,7 +279,7 @@ export default OutgoingCallDemo; -```js +```js lines highlight={12} import React, { useState, useEffect } from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -297,7 +354,7 @@ Using CSS you can customize the look and feel of the component in your app like -```ts +```ts lines highlight={13} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatOutgoingCall, @@ -333,7 +390,7 @@ export default OutgoingCallDemo; -```js +```js lines highlight={13} import React, { useState, useEffect } from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -369,8 +426,8 @@ export default OutgoingCallDemo; - -```css + +```css lines .cometchat-outgoing-call__avatar .cometchat-avatar { display: flex; justify-content: center; @@ -405,7 +462,7 @@ Here is a code snippet demonstrating how you can customize the functionality of -```ts +```ts lines highlight={12} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatOutgoingCall, @@ -442,7 +499,7 @@ export default OutgoingCallDemo; -```js +```js lines highlight={12} import React, { useState, useEffect } from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -511,7 +568,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines highlight={12} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatOutgoingCall, @@ -556,7 +613,7 @@ export default OutgoingCallDemo; -```js +```js lines highlight={12} import React, { useState, useEffect } from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -601,8 +658,8 @@ export default OutgoingCallDemo; - -```css + +```css lines .outgoing-call__title { color: #141414; text-align: center; @@ -628,7 +685,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines highlight={12} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatOutgoingCall, @@ -674,7 +731,7 @@ export default OutgoingCallDemo; -```js +```js lines highlight={12} import React, { useState, useEffect } from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -720,8 +777,8 @@ export default OutgoingCallDemo; - -```css + +```css lines .outgoing-call__subtitle { display: flex; justify-content: center; @@ -758,7 +815,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines highlight={13} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatAvatar, @@ -808,7 +865,7 @@ export default OutgoingCallDemo; -```js +```js lines highlight={13} import React, { useState, useEffect } from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -858,8 +915,8 @@ export default OutgoingCallDemo; - -```css + +```css lines .outgoing-call__avatar .cometchat-avatar, .outgoing-call__avatar .cometchat-avatar__image { width: 160px; @@ -896,7 +953,7 @@ Use the following code to achieve the customization shown above. -```ts +```ts lines highlight={12} import { CometChat } from "@cometchat/chat-sdk-javascript"; import { CometChatOutgoingCall, @@ -944,7 +1001,7 @@ export default OutgoingCallDemo; -```js +```js lines highlight={12} import React, { useState, useEffect } from "react"; import { CometChat } from "@cometchat/chat-sdk-javascript"; import { @@ -992,8 +1049,8 @@ export default OutgoingCallDemo; - -```css + +```css lines .outgoing-call__cancel-button-wrapper { height: 64px; display: flex; @@ -1026,3 +1083,38 @@ export default OutgoingCallDemo; + + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn't render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows nothing | `call` prop not provided or is `undefined` | Pass a valid `CometChat.Call` object from `CometChat.initiateCall()` | +| Callback not firing | Wrong prop name or signature | Check the Actions section for exact prop name and parameter types | +| Custom view not appearing | Returning `null` or `undefined` from view prop | Ensure view function returns valid JSX | +| No ringtone playing | `disableSoundForCalls` set to `true` or custom sound path invalid | Set `disableSoundForCalls={false}` and verify custom sound file path | +| SSR hydration error | Component uses browser APIs on server | Wrap in `useEffect` or dynamic import with `ssr: false`. See [Next.js Integration](/ui-kit/react/next-js-integration) | + + + + +--- + +## Next Steps + + + + Handle incoming voice and video calls + + + Add voice and video call buttons to your chat + + + Display call history and call log details + + + Overview of all calling capabilities + + diff --git a/ui-kit/react/overview.mdx b/ui-kit/react/overview.mdx index 42b82d980..7c71df3d8 100644 --- a/ui-kit/react/overview.mdx +++ b/ui-kit/react/overview.mdx @@ -1,16 +1,39 @@ --- title: "CometChat UI Kit For React" sidebarTitle: "Overview" +description: "Prebuilt, customizable React UI components for adding chat, voice, and video calling to your app. Supports React.js, Next.js, React Router, and Astro." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Install:** `npm install @cometchat/chat-uikit-react` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` — must complete before rendering any component +- **Key components:** `CometChatConversations`, `CometChatMessageList`, `CometChatMessageComposer`, `CometChatMessageHeader`, `CometChatUsers`, `CometChatGroups` +- **Theming:** Override CSS variables on `.cometchat` class. See [Theming](/ui-kit/react/theme) +- **Calling:** Requires separate `@cometchat/calls-sdk-javascript` package. See [Call Features](/ui-kit/react/call-features) +- **SSR:** Components require browser APIs — use client-side only rendering for Next.js/Astro + + The **CometChat UI Kit** for React is a powerful solution designed to seamlessly integrate chat functionality into applications. It provides a robust set of **prebuilt UI components** that are **modular, customizable, and highly scalable**, allowing developers to accelerate their development process with minimal effort. + +You must call `CometChatUIKit.init(UIKitSettings)` before rendering any UI Kit components or calling any SDK methods. Initialization must complete before login. + + + +**Auth Key** is for development/testing only. In production, generate **Auth Tokens** on your server using the REST API and pass them to the client. Never expose Auth Keys in production client code. + + + +**Server-Side Rendering (SSR):** CometChat UI Kit requires browser APIs (`window`, `WebSocket`, `document`). For Next.js or other SSR frameworks, ensure components render only on the client side. See the [Next.js Integration](/ui-kit/react/next-js-integration) guide. + + *** ## **Why Choose CometChat UI Kit?** * **Rapid Integration** – Prebuilt UI components for faster deployment. -* **Customizable & Flexible** – Modify the UI to align with your brand’s identity. +* **Customizable & Flexible** – Modify the UI to align with your brand's identity. * **Cross-Platform Compatibility** – Works seamlessly across various React-based frameworks. * **Scalable & Reliable** – Built on CometChat's **robust chat infrastructure** for enterprise-grade performance. @@ -43,67 +66,12 @@ href="https://link.cometchat.com/react-conversation-list-message" - -{/* [](https://link.cometchat.com/cometchat-demo) - -[](https://link.cometchat.com/react-conversation-list-message) */} - - > **Tip:** You can **fork** the sandbox, insert your **CometChat credentials** (App ID, Region, Auth Key) in the code, and immediately preview how the UI and messages respond in real time. *** ## **Integration** -{/* ### **Option 1: UI Kit Builder (Pre-Assembled UI)** - -A ready-to-use chat interface—configured via a UI Kit Builder—built on top of our UI Kits. - - - - - -**How It Works** - -* Toggle features like @mentions, reactions, media uploads, and more in a visual interface. -* Drag-and-drop or point-and-click to enable or disable components. -* Customize layouts and styles—no deep coding required. - -**Why It’s Great** - -* **Fastest Setup** – Minimal component wiring. -* **Continuous Customization** – Only turn on the features you want. -* **Fewer Moving Parts** – Reliable, pre-assembled UI that’s easy to maintain. - - - -} - href="/ui-kit/react/builder-integration" - horizontal -/> - -} - href="/ui-kit/react/builder-integration-nextjs" - horizontal -/> - -} - href="/ui-kit/react/builder-integration-react-router" - horizontal -/> - - - -*** - -### **Option 2: UI Components (Assemble It Yourself)** */} - A collection of individual components—like conversation lists, message lists, message composer, etc.—each with built-in chat logic so you can customize every element. @@ -114,9 +82,9 @@ A collection of individual components—like conversation lists, message lists, * Import the components you need from our UI Kits. * Arrange them in your desired layout, applying styling or customization as needed. -* You don’t need to rewrite the SDK calls yourself—each component already integrates with CometChat logic. +* You don't need to rewrite the SDK calls yourself—each component already integrates with CometChat logic. -**Why It’s Great** +**Why It's Great** * **Flexible Design** – You control the final UI arrangement. * **No Extra Overhead** – Implement only the features you need. @@ -154,23 +122,7 @@ A collection of individual components—like conversation lists, message lists, -*** - -## **Next Steps for Developers** - -1. **Learn the Basics** – [Key Concepts](/fundamentals/key-concepts). - -2. **Pick a Framework** – React.js or Next.js or React Router or Astro. - -3. **Follow the Setup Guide** – - - * **UI Components** – [React.js](/ui-kit/react/react-js-integration) or [Next.js](/ui-kit/react/next-js-integration) or [React Router](/ui-kit/react/react-router-integration) or [Astro](/ui-kit/react/astro-integration). - -4. **Customize UI** – Adjust [styles, themes](/ui-kit/react/theme), and [components](/ui-kit/react/components-overview). - -5. **Test & Deploy** – Run tests and launch your chat app. - -*** +*** ## **Helpful Resources** @@ -212,3 +164,22 @@ If you need assistance, check out: * [Developer Community](http://community.cometchat.com/) * [Support Portal](https://help.cometchat.com/hc/en-us/requests/new) + +--- + +## Next Steps + + + + Step-by-step setup guide for React.js applications + + + Browse all available prebuilt UI components + + + Chat features included out of the box + + + Customize colors, fonts, and styles to match your brand + + diff --git a/ui-kit/react/property-changes.mdx b/ui-kit/react/property-changes.mdx index 3358b3d16..f995b9276 100644 --- a/ui-kit/react/property-changes.mdx +++ b/ui-kit/react/property-changes.mdx @@ -1,6 +1,14 @@ --- title: "Property Changes" +description: "Detailed reference of renamed, added, and removed properties and methods when upgrading from CometChat React UI Kit v5 to v6." --- + +- **Migration scope:** Property and method changes between v5 and v6 for all components +- **Components affected:** Conversations, Users, Groups, Group Members, Message Header, Message List, Message Composer, Incoming Call, Outgoing Call, Call Buttons, Call Logs, CometChatLocalize +- **Key pattern change:** `datePattern` (DatePatterns) replaced with `CalendarObject`-based props across all components +- **Localization:** `setLocale` → `setCurrentLanguage`, `localize` → `getLocalizedString` +- **Full migration guide:** [Upgrading from v5](/ui-kit/react/upgrading-from-v5) + ## Conversations @@ -92,3 +100,24 @@ title: "Property Changes" | setDefaultLanguage | Sets the default lannguage if no language is passed in init method. | | isRTL | Returns true if the active language is rtl otherwise return false. | | getDir | Returns `rtl` or `ltr` based on the active language. | + +*** + +## Next Steps + + + + Full migration guide with breaking changes. + + + Explore all v6 prebuilt UI components. + + + Init, login, logout, and other UI Kit methods. + + + Subscribe to real-time events across components. + + + +*** diff --git a/ui-kit/react/react-conversation.mdx b/ui-kit/react/react-conversation.mdx index 03ab256f4..85fbea2a7 100644 --- a/ui-kit/react/react-conversation.mdx +++ b/ui-kit/react/react-conversation.mdx @@ -1,8 +1,18 @@ --- title: "Building A Conversation List + Message View" sidebarTitle: "Conversation List + Message View" +description: "Build a two-panel conversation list + message view layout in React.js with CometChat UI Kit." --- + +- **Package:** `@cometchat/chat-uikit-react` +- **Framework:** React.js +- **Key components:** `CometChatConversations` + `CometChatMessageList` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` +- **Parent guide:** [React.js Integration](/ui-kit/react/react-js-integration) + + + The **Conversation List + Message View** layout offers a seamless **two-panel chat interface**, commonly used in modern messaging applications like **WhatsApp Web, Slack, and Microsoft Teams**. This design enables users to switch between conversations effortlessly while keeping the chat window open, ensuring a **smooth, real-time messaging experience**. @@ -47,7 +57,7 @@ src/ -```tsx CometChatSelector.tsx +```tsx CometChatSelector.tsx lines import { useEffect, useState } from "react"; import { Conversation, @@ -118,7 +128,7 @@ export const CometChatSelector = (props: SelectorProps) => { -```css CometChatSelector.css +```css CometChatSelector.css lines /* Styles for the menu icon in the conversation header */ .selector-wrapper .cometchat-conversations .cometchat-list__header-menu .cometchat-button__icon { background: var(--cometchat-icon-color-primary); @@ -243,7 +253,7 @@ Now we will update the `App.tsx` & `App.css` files to import these new component -```tsx App.tsx +```tsx App.tsx lines import { useState } from "react"; import { CometChatMessageComposer, @@ -317,7 +327,7 @@ export default App; -```css App.css +```css App.css lines /* Root container settings */ #root { text-align: center; @@ -380,16 +390,56 @@ export default App; ### **Step 3: Run the project** -```powershell + + +```bash lines +npm run dev +``` + + + +```bash lines npm start ``` + + *** -## **Next Steps** -### **Enhance the User Experience** +## Common Failure Modes + + + + +| Symptom | Cause | Fix | +| --- | --- | --- | +| Component doesn’t render | `CometChatUIKit.init()` not called or not awaited | Ensure init completes before rendering. See [Methods](/ui-kit/react/methods) | +| Component renders but shows no data | User not logged in | Call `CometChatUIKit.login("UID")` after init | +| CSS/theme not applied | Missing CSS import | Add `@import url("@cometchat/chat-uikit-react/css-variables.css");` in your CSS | +| Blank screen after login | Component mounted before init/login completes | Use state to conditionally render after login resolves | +| Messages not loading | Invalid user/group object passed | Ensure you fetch the user/group via SDK before passing to components | + + + + +*** + +## **Next Steps** -* **[Advanced Customizations](/ui-kit/react/theme)** – Personalize the chat UI to align with your brand. + + + Personalize the chat UI to align with your brand. + + + Explore all available prebuilt UI components. + + + Return to the React.js setup guide. + + + Learn about messaging, real-time updates, and more. + + *** diff --git a/ui-kit/react/react-js-integration.mdx b/ui-kit/react/react-js-integration.mdx index 55d433935..0425e6112 100644 --- a/ui-kit/react/react-js-integration.mdx +++ b/ui-kit/react/react-js-integration.mdx @@ -1,8 +1,17 @@ --- title: "Getting Started With CometChat React UI Kit" sidebarTitle: "Integration" +description: "Step-by-step guide to integrate CometChat React UI Kit into your React.js application with Vite or Create React App." --- + +- **Package:** `@cometchat/chat-uikit-react` — `npm install @cometchat/chat-uikit-react` +- **Required setup:** `CometChatUIKit.init(UIKitSettings)` then `CometChatUIKit.login("UID")` — must complete before rendering +- **Init code:** `new UIKitSettingsBuilder().setAppId("APP_ID").setRegion("REGION").setAuthKey("AUTH_KEY").build()` +- **Framework:** React.js (this page) | [Next.js](/ui-kit/react/next-js-integration) | [React Router](/ui-kit/react/react-router-integration) | [Astro](/ui-kit/react/astro-integration) +- **All components:** [Components Overview](/ui-kit/react/components-overview) + + The **CometChat UI Kit for React** streamlines the integration of in-app chat functionality by providing a **comprehensive set of prebuilt UI components**. It offers seamless **theming options**, including **light and dark modes**, customizable fonts, colors, and extensive styling capabilities. With built-in support for **one-to-one and group conversations**, developers can efficiently enable chat features within their applications. Follow this guide to **quickly integrate chat functionality** using the CometChat React UI Kit. @@ -170,9 +179,17 @@ For secure authentication, use the [`Auth Token`](/ui-kit/react/methods#login-us + +**Auth Key** is for development/testing only. In production, generate **Auth Tokens** on your server using the REST API and pass them to the client. Never expose Auth Keys in production client code. + + + +You must call `CometChatUIKit.init(UIKitSettings)` before rendering any UI Kit components or calling any SDK methods. Initialization must complete before login. + + -```ts +```ts lines highlight={7-9} import { CometChatUIKit, UIKitSettingsBuilder } from "@cometchat/chat-uikit-react"; /** @@ -212,7 +229,7 @@ CometChatUIKit.init(UIKitSettings)! -```js +```js lines import { CometChatUIKit, UIKitSettingsBuilder } from "@cometchat/chat-uikit-react"; /** @@ -302,7 +319,7 @@ The **Login** method returns a **User object** containing all relevant details o -```ts +```ts lines highlight={3} import { CometChatUIKit } from "@cometchat/chat-uikit-react"; const UID = "UID"; // Replace with your actual UID @@ -325,7 +342,7 @@ CometChatUIKit.getLoggedinUser().then((user: CometChat.User | null) => { -```js +```js lines import { CometChatUIKit } from "@cometchat/chat-uikit-react"; const UID = "UID"; // Replace with your actual UID @@ -491,13 +508,43 @@ import { CometChatFrameProvider } from "@cometchat/ui-kit"; | `iframeId` | string | The DOM `id` of the target `