@cometchat/skills 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,993 @@
1
+ ---
2
+ name: cometchat-components
3
+ description: "Complete catalog of CometChat React UI Kit v6 components. Reference before writing integration code -- never invent component names."
4
+ license: "MIT"
5
+ compatibility: "@cometchat/chat-uikit-react ^6; @cometchat/chat-sdk-javascript ^4"
6
+ allowed-tools: "executeBash, readFile, fileSearch, listDirectory"
7
+ metadata:
8
+ author: "CometChat"
9
+ version: "3.0.0"
10
+ tags: "chat cometchat react components catalog reference ui-kit"
11
+ ---
12
+
13
+ ## Purpose
14
+
15
+ This is the single source of truth for CometChat React UI Kit v6 component names, props, and usage. **Check this catalog before writing any `<CometChat*>` JSX.** If a component is not listed here, it does not exist in the exported API.
16
+
17
+ All components are imported from `@cometchat/chat-uikit-react`. All SDK types are imported from `@cometchat/chat-sdk-javascript`.
18
+
19
+ ### Importing `CometChat.User` / `CometChat.Group` / etc.
20
+
21
+ `CometChat.User`, `CometChat.Group`, `CometChat.BaseMessage`, `CometChat.Conversation`, `CometChat.GroupMember`, `CometChat.TextMessage` are **classes** (runtime values), not pure types. That means the import strategy depends on how you use them:
22
+
23
+ **Pattern A — you call the class as a value or use it with `instanceof`.** Use a plain value import:
24
+
25
+ ```tsx
26
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
27
+
28
+ if (entity instanceof CometChat.User) { ... }
29
+ const user = await CometChat.getUser(uid);
30
+ ```
31
+
32
+ **Pattern B — you use it only as a type annotation, nowhere else.** Two options:
33
+
34
+ ```tsx
35
+ // Option 1: value import, reference the type via the namespace — TS lets this slide
36
+ // because CometChat is a class-namespace
37
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
38
+ function renderHeader(user: CometChat.User) { ... }
39
+
40
+ // Option 2: explicit type-only import
41
+ import type { CometChat } from "@cometchat/chat-sdk-javascript";
42
+ function renderHeader(user: CometChat.User) { ... }
43
+ ```
44
+
45
+ **Do NOT mix these.** If you write `import type { CometChat }` and then try `entity instanceof CometChat.User`, TypeScript strips the import at compile time and the code throws at runtime. If you write `import { CometChat }` but only reference `CometChat.User` as a type, `noUnusedLocals` can flag it (TS6133).
46
+
47
+ **Safest default:** use the plain value import (`import { CometChat }`). It always works; the TS6133 warning only fires in strict `noUnusedLocals` configs and can be fixed by actually using the runtime value (e.g. `instanceof CometChat.User`) or by adding an `eslint-disable-next-line` if you truly only need the type.
48
+
49
+ ---
50
+
51
+ ## 1. Core messaging
52
+
53
+ These are the components you use to build a chat experience. Most integrations use some combination of these seven.
54
+
55
+ ### CometChatConversations
56
+
57
+ Renders a scrollable list of the logged-in user's conversations (both 1:1 and group).
58
+
59
+ **Key props:**
60
+ | Prop | Type | Description |
61
+ |---|---|---|
62
+ | `activeConversation` | `CometChat.Conversation` | Highlights the currently selected conversation |
63
+ | `onItemClick` | `(conversation: CometChat.Conversation) => void` | Called when the user taps a conversation |
64
+ | `showSearchBar` | `boolean` | Shows a basic name-filter search bar above the list |
65
+ | `onSearchBarClicked` | `() => void` | Called when the search bar is clicked (use to swap in `CometChatSearch` for full search) |
66
+ | `conversationsRequestBuilder` | `CometChat.ConversationsRequestBuilder` | Customize which conversations to fetch (filters, limits) |
67
+
68
+ **Usage:**
69
+ ```tsx
70
+ <CometChatConversations
71
+ activeConversation={activeConversation}
72
+ onItemClick={(conversation) => setActiveConversation(conversation)}
73
+ />
74
+ ```
75
+
76
+ **Works with:** CometChatMessageHeader, CometChatMessageList, CometChatMessageComposer (two-pane layout)
77
+
78
+ ---
79
+
80
+ ### CometChatMessageList
81
+
82
+ Renders messages for a specific user or group conversation. Supports threaded views via `parentMessageId`.
83
+
84
+ **Key props:**
85
+ | Prop | Type | Description |
86
+ |---|---|---|
87
+ | `user` | `CometChat.User` | Show messages with this user (mutually exclusive with `group`) |
88
+ | `group` | `CometChat.Group` | Show messages in this group (mutually exclusive with `user`) |
89
+ | `parentMessageId` | `number` | If set, shows only replies to this message (thread view) |
90
+ | `templates` | `CometChatMessageTemplate[]` | Custom message bubble templates |
91
+ | `messagesRequestBuilder` | `CometChat.MessagesRequestBuilder` | Customize message fetching |
92
+
93
+ **Usage:**
94
+ ```tsx
95
+ <CometChatMessageList user={selectedUser} />
96
+ ```
97
+
98
+ **Works with:** CometChatMessageHeader (above), CometChatMessageComposer (below)
99
+
100
+ ---
101
+
102
+ ### CometChatMessageComposer
103
+
104
+ A text input with send button, attachment options, and emoji support. Sends messages to the specified user or group.
105
+
106
+ **Key props:**
107
+ | Prop | Type | Description |
108
+ |---|---|---|
109
+ | `user` | `CometChat.User` | Send messages to this user (mutually exclusive with `group`) |
110
+ | `group` | `CometChat.Group` | Send messages to this group (mutually exclusive with `user`) |
111
+ | `parentMessageId` | `number` | If set, sends replies to this message (thread mode) |
112
+ | `onSendButtonClick` | `(message: CometChat.BaseMessage) => void` | Called when send is clicked |
113
+
114
+ **Usage:**
115
+ ```tsx
116
+ <CometChatMessageComposer user={selectedUser} />
117
+ ```
118
+
119
+ **Works with:** CometChatMessageList (above), CometChatMessageHeader (at top of message area)
120
+
121
+ ---
122
+
123
+ ### CometChatCompactMessageComposer
124
+
125
+ A rich-text variant of the message composer with formatting toolbar (bold, italic, code, etc.). Same props as CometChatMessageComposer.
126
+
127
+ **Key props:**
128
+ | Prop | Type | Description |
129
+ |---|---|---|
130
+ | `user` | `CometChat.User` | Send messages to this user |
131
+ | `group` | `CometChat.Group` | Send messages to this group |
132
+ | `parentMessageId` | `number` | Thread mode |
133
+ | `onSendButtonClick` | `(message: CometChat.BaseMessage) => void` | Called on send |
134
+
135
+ **Usage:**
136
+ ```tsx
137
+ <CometChatCompactMessageComposer user={selectedUser} />
138
+ ```
139
+
140
+ **Works with:** Same as CometChatMessageComposer -- drop-in replacement for rich text
141
+
142
+ ---
143
+
144
+ ### CometChatMessageHeader
145
+
146
+ Displays the name, avatar, and status of the user or group at the top of a message view. Supports a menu slot and search.
147
+
148
+ **Key props:**
149
+ | Prop | Type | Description |
150
+ |---|---|---|
151
+ | `user` | `CometChat.User` | Show header for this user |
152
+ | `group` | `CometChat.Group` | Show header for this group |
153
+ | `onItemClick` | `() => void` | Called when the header info area is clicked (use to open details panel) |
154
+ | `onBack` | `() => void` | Called when back button is clicked |
155
+ | `auxiliaryButtonView` | `JSX.Element` | Custom button area (e.g., CometChatCallButtons) |
156
+ | `showBackButton` | `boolean` | Show a back button (for mobile/nested views) |
157
+ | `showSearchOption` | `boolean` | Show a search icon in the header |
158
+ | `onSearchOptionClicked` | `() => void` | Called when search icon is clicked |
159
+ | `hideVideoCallButton` | `boolean` | Hide the video call button |
160
+ | `hideVoiceCallButton` | `boolean` | Hide the voice call button |
161
+
162
+ **Usage:**
163
+ ```tsx
164
+ <CometChatMessageHeader
165
+ user={selectedUser}
166
+ onItemClick={() => setShowDetails(true)}
167
+ auxiliaryButtonView={<CometChatCallButtons user={selectedUser} />}
168
+ />
169
+ ```
170
+
171
+ **Works with:** CometChatMessageList (below), CometChatCallButtons (in auxiliaryButtonView slot)
172
+
173
+ ---
174
+
175
+ ### CometChatSearch
176
+
177
+ Full-featured dual-scope search: searches across conversations AND messages with filter chips. This is the primary search component.
178
+
179
+ **Key props:**
180
+ | Prop | Type | Description |
181
+ |---|---|---|
182
+ | `onConversationClicked` | `(conversation: CometChat.Conversation) => void` | Called when a conversation result is clicked |
183
+ | `onMessageClicked` | `(message: CometChat.BaseMessage) => void` | Called when a message result is clicked |
184
+
185
+ **Usage:**
186
+ ```tsx
187
+ <CometChatSearch
188
+ onConversationClicked={(conv) => navigateToConversation(conv)}
189
+ onMessageClicked={(msg) => scrollToMessage(msg)}
190
+ />
191
+ ```
192
+
193
+ **Works with:** CometChatConversations (replaces the list when search is active)
194
+
195
+ ---
196
+
197
+ ### CometChatThreadHeader
198
+
199
+ Header bar for a threaded message view. Shows the parent message and a close button.
200
+
201
+ **Key props:**
202
+ | Prop | Type | Description |
203
+ |---|---|---|
204
+ | `parentMessage` | `CometChat.BaseMessage` | The message that started the thread |
205
+ | `onClose` | `() => void` | Called when the user closes the thread view |
206
+
207
+ **Usage:**
208
+ ```tsx
209
+ <CometChatThreadHeader
210
+ parentMessage={threadParentMessage}
211
+ onClose={() => setThreadParent(null)}
212
+ />
213
+ ```
214
+
215
+ **Works with:** CometChatMessageList (with `parentMessageId`), CometChatMessageComposer (with `parentMessageId`)
216
+
217
+ ---
218
+
219
+ ## 2. Lists and selection
220
+
221
+ Components for browsing and selecting users, groups, and group members.
222
+
223
+ ### CometChatUsers
224
+
225
+ A scrollable list of users. Used for starting new conversations or browsing the user directory.
226
+
227
+ **Key props:**
228
+ | Prop | Type | Description |
229
+ |---|---|---|
230
+ | `onItemClick` | `(user: CometChat.User) => void` | Called when a user is selected |
231
+ | `usersRequestBuilder` | `CometChat.UsersRequestBuilder` | Customize which users to fetch |
232
+
233
+ **Usage:**
234
+ ```tsx
235
+ <CometChatUsers onItemClick={(user) => startConversation(user)} />
236
+ ```
237
+
238
+ **Works with:** CometChatMessageHeader, CometChatMessageList, CometChatMessageComposer (after selection)
239
+
240
+ ---
241
+
242
+ ### CometChatGroups
243
+
244
+ A scrollable list of groups. Used for browsing and joining groups.
245
+
246
+ **Key props:**
247
+ | Prop | Type | Description |
248
+ |---|---|---|
249
+ | `onItemClick` | `(group: CometChat.Group) => void` | Called when a group is selected |
250
+ | `groupsRequestBuilder` | `CometChat.GroupsRequestBuilder` | Customize which groups to fetch |
251
+
252
+ **Usage:**
253
+ ```tsx
254
+ <CometChatGroups onItemClick={(group) => openGroup(group)} />
255
+ ```
256
+
257
+ **Works with:** CometChatMessageHeader, CometChatMessageList, CometChatMessageComposer (after selection)
258
+
259
+ ---
260
+
261
+ ### CometChatGroupMembers
262
+
263
+ Displays members of a specific group with their roles (owner, admin, member).
264
+
265
+ **Key props:**
266
+ | Prop | Type | Description |
267
+ |---|---|---|
268
+ | `group` | `CometChat.Group` | The group whose members to display (required) |
269
+ | `onItemClick` | `(member: CometChat.GroupMember) => void` | Called when a member is selected |
270
+
271
+ **Usage:**
272
+ ```tsx
273
+ <CometChatGroupMembers group={selectedGroup} />
274
+ ```
275
+
276
+ **Works with:** Group details panel, CometChatGroups
277
+
278
+ ---
279
+
280
+ ### CometChatSearchBar
281
+
282
+ A standalone search input component. Used for filtering within other components.
283
+
284
+ **Key props:**
285
+ | Prop | Type | Description |
286
+ |---|---|---|
287
+ | `onSearch` | `(text: string) => void` | Called as the user types |
288
+ | `text` | `string` | Controlled input value |
289
+
290
+ **Usage:**
291
+ ```tsx
292
+ <CometChatSearchBar onSearch={(text) => filterUsers(text)} />
293
+ ```
294
+
295
+ **Works with:** Any list component for client-side filtering
296
+
297
+ ---
298
+
299
+ ## 3. Calls
300
+
301
+ Components for voice and video calling.
302
+
303
+ ### CometChatCallButtons
304
+
305
+ Renders voice and video call buttons. Typically placed in the `auxiliaryButtonView` prop of CometChatMessageHeader.
306
+
307
+ **Key props:**
308
+ | Prop | Type | Description |
309
+ |---|---|---|
310
+ | `user` | `CometChat.User` | Call this user |
311
+ | `group` | `CometChat.Group` | Call this group |
312
+ | `hideVideoCallButton` | `boolean` | Hide the video call button |
313
+ | `hideVoiceCallButton` | `boolean` | Hide the voice call button |
314
+
315
+ **Usage:**
316
+ ```tsx
317
+ <CometChatCallButtons user={selectedUser} />
318
+ ```
319
+
320
+ **Works with:** CometChatMessageHeader (in `menu` prop), CometChatIncomingCall (at app root)
321
+
322
+ ---
323
+
324
+ ### CometChatIncomingCall
325
+
326
+ Renders an incoming call notification overlay. Mount this at the app root so it can show incoming calls from any screen.
327
+
328
+ **Key props:** None required -- it auto-listens for incoming call events.
329
+
330
+ **Usage:**
331
+ ```tsx
332
+ // At your app root, always mounted:
333
+ <CometChatIncomingCall />
334
+ ```
335
+
336
+ **Works with:** CometChatCallButtons (triggers outgoing calls that the other user sees as incoming)
337
+
338
+ ---
339
+
340
+ ### CometChatOutgoingCall
341
+
342
+ Renders the outgoing call screen (ringing state). Automatically shown when the user initiates a call.
343
+
344
+ **Key props:** None required -- auto-triggered by call initiation.
345
+
346
+ **Usage:**
347
+ ```tsx
348
+ <CometChatOutgoingCall />
349
+ ```
350
+
351
+ **Works with:** CometChatCallButtons
352
+
353
+ ---
354
+
355
+ ### CometChatOngoingCall
356
+
357
+ Renders the active call screen with video feeds, mute/unmute, and hang-up controls.
358
+
359
+ **Key props:** None required -- auto-triggered when a call connects.
360
+
361
+ **Usage:**
362
+ ```tsx
363
+ <CometChatOngoingCall />
364
+ ```
365
+
366
+ **Works with:** CometChatIncomingCall, CometChatOutgoingCall
367
+
368
+ ---
369
+
370
+ ### CometChatCallLogs
371
+
372
+ Displays a history of past voice and video calls.
373
+
374
+ **Key props:** None required for basic usage.
375
+
376
+ **Usage:**
377
+ ```tsx
378
+ <CometChatCallLogs />
379
+ ```
380
+
381
+ **Works with:** Tab-based layouts (as one of the tabs alongside Conversations, Users, Groups)
382
+
383
+ ---
384
+
385
+ ## 4. Interactions
386
+
387
+ Components for message reactions and emoji.
388
+
389
+ ### CometChatReactions
390
+
391
+ Displays reaction badges on a message (e.g., thumbs-up x3). Automatically rendered inside message bubbles when reactions are enabled.
392
+
393
+ **Key props:** Typically used internally by the message list. Not usually instantiated directly.
394
+
395
+ ---
396
+
397
+ ### CometChatReactionList
398
+
399
+ Shows a detailed list of who reacted with what emoji on a specific message.
400
+
401
+ **Key props:** Used internally. Shown when the user clicks on a reaction badge.
402
+
403
+ ---
404
+
405
+ ### CometChatEmojiKeyboard
406
+
407
+ A full emoji picker. Automatically rendered inside the message composer when the emoji button is clicked.
408
+
409
+ **Key props:** Used internally by CometChatMessageComposer. Not usually instantiated directly.
410
+
411
+ ---
412
+
413
+ ### CometChatReactionInfo
414
+
415
+ Tooltip or popover showing reaction details on hover.
416
+
417
+ **Key props:** Used internally by the message list. Not usually instantiated directly.
418
+
419
+ ---
420
+
421
+ ## 5. AI
422
+
423
+ AI-powered assistant components. These require AI features (Smart Chat Features) to be enabled in your CometChat dashboard at **Chat & Messaging → Features → Smart Chat Features**.
424
+
425
+ ### CometChatAIAssistantChat
426
+
427
+ An AI chatbot interface that users can interact with for automated responses. Typically rendered inside a panel or modal triggered from the message header.
428
+
429
+ **Prerequisites:** Enable "Conversation Starter" and/or "Smart Replies" in the dashboard.
430
+
431
+ **Usage:**
432
+ ```tsx
433
+ <CometChatAIAssistantChat />
434
+ ```
435
+
436
+ ---
437
+
438
+ ### CometChatAIAssistantChatHistory
439
+
440
+ Displays past AI assistant interactions. Used alongside `CometChatAIAssistantChat` to show conversation history with the AI.
441
+
442
+ **Usage:**
443
+ ```tsx
444
+ <CometChatAIAssistantChatHistory />
445
+ ```
446
+
447
+ ---
448
+
449
+ ### CometChatAIAssistantTools
450
+
451
+ Renders AI tool options (summarize conversation, translate message, etc.) that can be applied to messages or conversations.
452
+
453
+ **Prerequisites:** Enable "Conversation Summary" and/or other AI tools in the dashboard.
454
+
455
+ **Usage:**
456
+ ```tsx
457
+ <CometChatAIAssistantTools />
458
+ ```
459
+
460
+ > **Note:** For detailed props, configuration options, and customization of AI components, query the docs MCP — these components' APIs evolve with CometChat's AI feature releases.
461
+
462
+ ### CometChatStreamMessageBubble
463
+
464
+ Renders a streaming AI message with a typing animation effect. Used internally by AI assistant features.
465
+
466
+ ### CometChatAIAssistantMessageBubble
467
+
468
+ Renders AI assistant response bubbles with special formatting. Used internally by AI features.
469
+
470
+ ---
471
+
472
+ ## 5b. Moderation and utility components
473
+
474
+ These are exported but typically rendered internally by the kit. You may need them for advanced customization.
475
+
476
+ ### CometChatFlagMessageDialog
477
+
478
+ A dialog for reporting/flagging messages. Rendered internally when a user reports a message.
479
+
480
+ ### CometChatMessageInformation
481
+
482
+ Shows message delivery and read receipt details (who received, who read, timestamps). Useful for building a message info panel.
483
+
484
+ ---
485
+
486
+ ## 5c. Text formatters
487
+
488
+ These are not React components — they are formatter classes that customize how text is rendered in message bubbles. Pass them via the `textFormatters` prop on `CometChatMessageList`.
489
+
490
+ | Formatter | Purpose |
491
+ |---|---|
492
+ | `CometChatTextFormatter` | Base class for custom formatters |
493
+ | `CometChatUrlsFormatter` | Auto-links URLs in messages |
494
+ | `CometChatMentionsFormatter` | Renders @mentions with styling + click handlers |
495
+ | `CometChatTextHighlightFormatter` | Highlights search terms in messages |
496
+ | `CometChatRichTextFormatter` | Renders rich text (bold, italic, etc.) |
497
+ | `CometChatMarkdownFormatter` | Renders markdown syntax in messages |
498
+
499
+ All imported from `@cometchat/chat-uikit-react`. To customize text rendering, create a class extending `CometChatTextFormatter` and pass it in the `textFormatters` array.
500
+
501
+ ---
502
+
503
+ ## 6. Infrastructure
504
+
505
+ These are not visual components -- they handle initialization, login state, and configuration.
506
+
507
+ ### CometChatUIKit
508
+
509
+ The main entry point for initialization and authentication. This is a static class, not a React component.
510
+
511
+ **Key methods:**
512
+ | Method | Description |
513
+ |---|---|
514
+ | `CometChatUIKit.init(settings)` | Initialize the SDK. Returns a Promise. Must be called once before any component renders. |
515
+ | `CometChatUIKit.login(uid)` | Log in with a user ID (dev mode). Returns `Promise<CometChat.User>`. Safe to call after a prior login completes (no-op), but **not concurrently** — two overlapping calls throw *"Please wait until the previous login request ends."* Use `cometchat-core`'s `ensureLoggedIn` helper to dedupe. |
516
+ | `CometChatUIKit.loginWithAuthToken(token)` | Log in with an auth token (production). Returns `Promise<CometChat.User>`. |
517
+ | `CometChatUIKit.getLoggedinUser()` | Get the currently logged-in user. Returns `Promise<CometChat.User \| null>`. |
518
+ | `CometChatUIKit.logout()` | Log out the current user. Returns a Promise. |
519
+ | `CometChatUIKit.createUser(user)` | Create a CometChat user (requires Auth Key). For server-side user management, see `cometchat-production`. |
520
+ | `CometChatUIKit.updateUser(user)` | Update a CometChat user (requires Auth Key). |
521
+ | `CometChatUIKit.isInitialized()` | Returns `boolean` — whether `init()` has been called. |
522
+
523
+ **Usage** (bare-API illustration — in real code, wrap `login` in an
524
+ in-flight guard so React StrictMode doesn't fire it twice; see
525
+ `cometchat-core` § 2 for the `ensureLoggedIn` helper):
526
+ ```typescript
527
+ import { CometChatUIKit } from "@cometchat/chat-uikit-react";
528
+
529
+ await CometChatUIKit.init(settings);
530
+ await CometChatUIKit.login("cometchat-uid-1");
531
+ ```
532
+
533
+ ---
534
+
535
+ ### CometChatUIKitLoginListener
536
+
537
+ Tracks the logged-in user synchronously. Unlike `CometChatUIKit.getLoggedinUser()` (which is async/Promise-based), this provides **synchronous** access to the current user — useful for guards and conditional rendering.
538
+
539
+ **Key methods:**
540
+ | Method | Description |
541
+ |---|---|
542
+ | `CometChatUIKitLoginListener.getLoggedInUser()` | Returns the currently logged-in `CometChat.User` synchronously, or `null` |
543
+
544
+ **When to use which:**
545
+ - `CometChatUIKit.getLoggedinUser()` — async, returns a Promise. Use in `useEffect` or async functions.
546
+ - `CometChatUIKitLoginListener.getLoggedInUser()` — synchronous. Use for immediate checks (e.g., redirect if not logged in, guard a route).
547
+
548
+ ---
549
+
550
+ ### UIKitSettingsBuilder
551
+
552
+ Builder class for creating the settings object passed to `CometChatUIKit.init()`.
553
+
554
+ **Key methods:**
555
+ | Method | Description |
556
+ |---|---|
557
+ | `.setAppId(appId: string)` | Set the CometChat app ID (required) |
558
+ | `.setRegion(region: string)` | Set the region: `"us"`, `"eu"`, or `"in"` (required) |
559
+ | `.setAuthKey(authKey: string)` | Set the auth key (required for `login(uid)` in dev mode) |
560
+ | `.subscribePresenceForAllUsers()` | Enable presence (online/offline) for all users |
561
+ | `.subscribePresenceForFriends()` | Enable presence only for friends list |
562
+ | `.subscribePresenceForRoles(roles)` | Enable presence for specific user roles |
563
+ | `.setAutoEstablishSocketConnection(bool)` | Control WebSocket auto-connect (default: true) |
564
+ | `.setAdminHost(host)` | Override admin URL (dedicated deployments only) |
565
+ | `.setClientHost(host)` | Override client URL (dedicated deployments only) |
566
+ | `.build()` | Returns the settings object |
567
+
568
+ **Usage:**
569
+ ```typescript
570
+ import { UIKitSettingsBuilder } from "@cometchat/chat-uikit-react";
571
+
572
+ const settings = new UIKitSettingsBuilder()
573
+ .setAppId("your-app-id")
574
+ .setRegion("us")
575
+ .setAuthKey("your-auth-key")
576
+ .subscribePresenceForAllUsers()
577
+ .build();
578
+ ```
579
+
580
+ ---
581
+
582
+ ## Composition patterns
583
+
584
+ These are the standard ways to combine CometChat components into complete
585
+ experiences. Use these as starting points, then customize with props.
586
+
587
+ > **Composer note:** Both `CometChatMessageComposer` and
588
+ > `CometChatCompactMessageComposer` exist. The compact variant includes
589
+ > rich text editing by default. The sample app uses the compact variant
590
+ > everywhere. Use whichever fits — the props are identical.
591
+
592
+ ### Multi-conversation (two-pane)
593
+
594
+ The most common pattern. A conversation list on the left, message view on the right.
595
+
596
+ **Key details from the v6 sample app:**
597
+ - Store the full `CometChat.Conversation` object (not just user/group) — you need it for `activeConversation` highlighting and conversation-level operations
598
+ - Pass `activeConversation` to `CometChatConversations` so the selected item is visually highlighted
599
+ - Derive user/group from the conversation at render time using `getConversationWith()`
600
+
601
+ ```tsx
602
+ import { useState } from "react";
603
+ import {
604
+ CometChatConversations,
605
+ CometChatMessageHeader,
606
+ CometChatMessageList,
607
+ CometChatMessageComposer,
608
+ } from "@cometchat/chat-uikit-react";
609
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
610
+
611
+ function MultiConversation() {
612
+ const [activeConversation, setActiveConversation] = useState<CometChat.Conversation>();
613
+
614
+ // Derive user/group from the active conversation
615
+ const entity = activeConversation?.getConversationWith();
616
+ const selectedUser = entity instanceof CometChat.User ? entity : undefined;
617
+ const selectedGroup = entity instanceof CometChat.Group ? entity : undefined;
618
+
619
+ return (
620
+ <div style={{ display: "flex", height: "100vh" }}>
621
+ <div style={{ width: "360px", borderRight: "1px solid #eee" }}>
622
+ <CometChatConversations
623
+ activeConversation={activeConversation}
624
+ onItemClick={(conv) => setActiveConversation(conv)}
625
+ />
626
+ </div>
627
+ <div style={{ flex: 1, display: "flex", flexDirection: "column" }}>
628
+ {selectedUser && (
629
+ <>
630
+ <CometChatMessageHeader user={selectedUser} />
631
+ <CometChatMessageList user={selectedUser} />
632
+ <CometChatMessageComposer user={selectedUser} />
633
+ </>
634
+ )}
635
+ {selectedGroup && (
636
+ <>
637
+ <CometChatMessageHeader group={selectedGroup} />
638
+ <CometChatMessageList group={selectedGroup} />
639
+ <CometChatMessageComposer group={selectedGroup} />
640
+ </>
641
+ )}
642
+ </div>
643
+ </div>
644
+ );
645
+ }
646
+ ```
647
+
648
+ ---
649
+
650
+ ### Single thread
651
+
652
+ One chat window for a known user or group. No conversation list.
653
+
654
+ ```tsx
655
+ import {
656
+ CometChatMessageHeader,
657
+ CometChatMessageList,
658
+ CometChatMessageComposer,
659
+ } from "@cometchat/chat-uikit-react";
660
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
661
+
662
+ interface SingleThreadProps {
663
+ user?: CometChat.User;
664
+ group?: CometChat.Group;
665
+ }
666
+
667
+ function SingleThread({ user, group }: SingleThreadProps) {
668
+ return (
669
+ <div style={{ display: "flex", flexDirection: "column", height: "100%" }}>
670
+ {user && <CometChatMessageHeader user={user} />}
671
+ {group && <CometChatMessageHeader group={group} />}
672
+ {user && <CometChatMessageList user={user} />}
673
+ {group && <CometChatMessageList group={group} />}
674
+ {user && <CometChatMessageComposer user={user} />}
675
+ {group && <CometChatMessageComposer group={group} />}
676
+ </div>
677
+ );
678
+ }
679
+ ```
680
+
681
+ To target a specific user, resolve them first:
682
+
683
+ ```tsx
684
+ const [targetUser, setTargetUser] = useState<CometChat.User>();
685
+
686
+ useEffect(() => {
687
+ CometChat.getUser("seller-uid-123").then(setTargetUser);
688
+ }, []);
689
+
690
+ if (!targetUser) return null;
691
+ return <SingleThread user={targetUser} />;
692
+ ```
693
+
694
+ ---
695
+
696
+ ### Full messenger (tab-based)
697
+
698
+ A tab bar with Chats, Calls, Users, and Groups. Users can browse, start conversations, and make calls.
699
+
700
+ ```tsx
701
+ import { useState } from "react";
702
+ import {
703
+ CometChatConversations,
704
+ CometChatCallLogs,
705
+ CometChatUsers,
706
+ CometChatGroups,
707
+ CometChatMessageHeader,
708
+ CometChatMessageList,
709
+ CometChatMessageComposer,
710
+ } from "@cometchat/chat-uikit-react";
711
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
712
+
713
+ type Tab = "chats" | "calls" | "users" | "groups";
714
+
715
+ function FullMessenger() {
716
+ const [activeTab, setActiveTab] = useState<Tab>("chats");
717
+ const [activeConversation, setActiveConversation] = useState<CometChat.Conversation>();
718
+ const [selectedUser, setSelectedUser] = useState<CometChat.User>();
719
+ const [selectedGroup, setSelectedGroup] = useState<CometChat.Group>();
720
+
721
+ function selectUser(user: CometChat.User) {
722
+ setSelectedUser(user);
723
+ setSelectedGroup(undefined);
724
+ }
725
+
726
+ function selectGroup(group: CometChat.Group) {
727
+ setSelectedUser(undefined);
728
+ setSelectedGroup(group);
729
+ }
730
+
731
+ return (
732
+ <div style={{ display: "flex", height: "100vh" }}>
733
+ <div style={{ width: "360px", display: "flex", flexDirection: "column" }}>
734
+ {/* Tab content */}
735
+ <div style={{ flex: 1 }}>
736
+ {activeTab === "chats" && (
737
+ <CometChatConversations
738
+ activeConversation={activeConversation}
739
+ onItemClick={(conv) => {
740
+ setActiveConversation(conv);
741
+ const entity = conv.getConversationWith();
742
+ if (entity instanceof CometChat.User) selectUser(entity);
743
+ else if (entity instanceof CometChat.Group) selectGroup(entity);
744
+ }}
745
+ />
746
+ )}
747
+ {activeTab === "calls" && (
748
+ <CometChatCallLogs
749
+ onItemClick={(call) => {
750
+ // Call log items show call details, not a message view.
751
+ // Use the call's participants to start a new call or
752
+ // navigate to the conversation.
753
+ }}
754
+ />
755
+ )}
756
+ {activeTab === "users" && (
757
+ <CometChatUsers
758
+ activeUser={selectedUser}
759
+ onItemClick={selectUser}
760
+ />
761
+ )}
762
+ {activeTab === "groups" && (
763
+ <CometChatGroups
764
+ activeGroup={selectedGroup}
765
+ onItemClick={selectGroup}
766
+ />
767
+ )}
768
+ </div>
769
+ {/* Tab bar at the bottom */}
770
+ <div style={{ display: "flex", borderTop: "1px solid #eee" }}>
771
+ {(["chats", "calls", "users", "groups"] as Tab[]).map((tab) => (
772
+ <button
773
+ key={tab}
774
+ onClick={() => setActiveTab(tab)}
775
+ style={{ flex: 1, padding: 12, fontWeight: activeTab === tab ? "bold" : "normal" }}
776
+ >
777
+ {tab.charAt(0).toUpperCase() + tab.slice(1)}
778
+ </button>
779
+ ))}
780
+ </div>
781
+ </div>
782
+ <div style={{ flex: 1, display: "flex", flexDirection: "column" }}>
783
+ {selectedUser && (
784
+ <>
785
+ <CometChatMessageHeader user={selectedUser} />
786
+ <CometChatMessageList user={selectedUser} />
787
+ <CometChatMessageComposer user={selectedUser} />
788
+ </>
789
+ )}
790
+ {selectedGroup && (
791
+ <>
792
+ <CometChatMessageHeader group={selectedGroup} />
793
+ <CometChatMessageList group={selectedGroup} />
794
+ <CometChatMessageComposer group={selectedGroup} />
795
+ </>
796
+ )}
797
+ </div>
798
+ </div>
799
+ );
800
+ }
801
+ ```
802
+
803
+ ---
804
+
805
+ ### Threading
806
+
807
+ Threading is NOT automatic. The kit's **default** is `hideReplyInThreadOption={false}` — so a "Reply in Thread" entry shows up in every message's action menu out of the box, **even when the integrator hasn't wired a thread panel**. A user who clicks it sees nothing happen. That's why every `<CometChatMessageList>` in the `cometchat-placement` patterns uses `hideReplyInThreadOption` by default.
808
+
809
+ **To enable threading** in an experience that has room for a thread panel (typically a two-pane messenger or route-based chat — not a compact drawer or widget):
810
+
811
+ 1. Remove the `hideReplyInThreadOption` prop from the main `CometChatMessageList`.
812
+ 2. Wire `onThreadRepliesClick` to capture the thread message (pattern below).
813
+ 3. Render the thread panel as a side panel or overlay. The thread panel has its OWN `CometChatMessageList` + `CometChatMessageComposer` scoped via `parentMessageId`.
814
+
815
+ Full pattern:
816
+
817
+ ```tsx
818
+ import { useState } from "react";
819
+ import {
820
+ CometChatMessageList,
821
+ CometChatMessageComposer,
822
+ CometChatThreadHeader,
823
+ } from "@cometchat/chat-uikit-react";
824
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
825
+
826
+ // 1. In your main message view, capture the thread click:
827
+ <CometChatMessageList
828
+ user={selectedUser}
829
+ onThreadRepliesClick={(message: CometChat.BaseMessage) => {
830
+ setThreadMessage(message);
831
+ setShowThread(true);
832
+ }}
833
+ />
834
+
835
+ // 2. Render the thread panel as a side panel:
836
+ interface ThreadPanelProps {
837
+ parentMessage: CometChat.BaseMessage;
838
+ user?: CometChat.User;
839
+ group?: CometChat.Group;
840
+ onClose: () => void;
841
+ }
842
+
843
+ function ThreadPanel({ parentMessage, user, group, onClose }: ThreadPanelProps) {
844
+ const parentId = parentMessage.getId();
845
+
846
+ return (
847
+ <div style={{ width: "400px", display: "flex", flexDirection: "column", borderLeft: "1px solid #eee" }}>
848
+ <CometChatThreadHeader parentMessage={parentMessage} onClose={onClose} />
849
+ {user && <CometChatMessageList user={user} parentMessageId={parentId} />}
850
+ {group && <CometChatMessageList group={group} parentMessageId={parentId} />}
851
+ {user && <CometChatMessageComposer user={user} parentMessageId={parentId} />}
852
+ {group && <CometChatMessageComposer group={group} parentMessageId={parentId} />}
853
+ </div>
854
+ );
855
+ }
856
+ ```
857
+
858
+ **Key details:**
859
+ - `onThreadRepliesClick` receives the full `CometChat.BaseMessage` (not just an ID)
860
+ - `CometChatThreadHeader` shows the parent message content + close button
861
+ - The scoped `CometChatMessageList` with `parentMessageId` shows only thread replies
862
+ - The scoped `CometChatMessageComposer` with `parentMessageId` sends replies to the thread
863
+
864
+ ---
865
+
866
+ ### Search integration
867
+
868
+ Search overlays **alongside** the conversation list — it does NOT replace it. The conversations list stays mounted; search appears as a sibling panel.
869
+
870
+ **Global search (across all conversations):**
871
+
872
+ ```tsx
873
+ import { useState } from "react";
874
+ import { CometChatConversations, CometChatSearch } from "@cometchat/chat-uikit-react";
875
+
876
+ function ConversationsWithSearch({ onSelectConversation }) {
877
+ const [showSearch, setShowSearch] = useState(false);
878
+
879
+ return (
880
+ <div style={{ position: "relative" }}>
881
+ {/* Conversations always stay mounted */}
882
+ <CometChatConversations
883
+ showSearchBar={true}
884
+ onSearchBarClicked={() => setShowSearch(true)}
885
+ activeConversation={activeConversation}
886
+ onItemClick={onSelectConversation}
887
+ />
888
+
889
+ {/* Search overlays on top when active */}
890
+ {showSearch && (
891
+ <div style={{ position: "absolute", inset: 0, zIndex: 10, background: "#fff" }}>
892
+ <CometChatSearch
893
+ onConversationClicked={(conv) => {
894
+ setShowSearch(false);
895
+ onSelectConversation(conv);
896
+ }}
897
+ onMessageClicked={(msg) => {
898
+ setShowSearch(false);
899
+ // navigate to the message's conversation
900
+ }}
901
+ />
902
+ </div>
903
+ )}
904
+ </div>
905
+ );
906
+ }
907
+ ```
908
+
909
+ **In-conversation search (within the active chat):**
910
+
911
+ ```tsx
912
+ // Add search button to the message header:
913
+ <CometChatMessageHeader
914
+ user={selectedUser}
915
+ showSearchOption={true}
916
+ onSearchOptionClicked={() => setShowMessageSearch(true)}
917
+ />
918
+
919
+ // Show CometChatSearch scoped to the current user/group:
920
+ {showMessageSearch && (
921
+ <CometChatSearch
922
+ uid={selectedUser?.getUid()}
923
+ guid={selectedGroup?.getGuid()}
924
+ onMessageClicked={(msg) => {
925
+ setShowMessageSearch(false);
926
+ // scroll to the message in the message list
927
+ }}
928
+ />
929
+ )}
930
+ ```
931
+
932
+ ---
933
+
934
+ ### Details panel
935
+
936
+ User and group detail panels are **custom-built** — there is no pre-built `CometChatUserDetails` or `CometChatGroupDetails` export in the UI Kit. The v6 sample app has reference implementations at `sample-app/src/components/CometChatDetails/`.
937
+
938
+ **For user details:** build a custom component using `CometChatAvatar` + user info + action buttons (block/unblock). Fetch the pattern from the sample app's `CometChatUserDetails.tsx`.
939
+
940
+ **For group details:** build a custom component and use these real UI Kit components inside it:
941
+
942
+ ```tsx
943
+ // Open details from the message header:
944
+ <CometChatMessageHeader
945
+ user={selectedUser}
946
+ group={selectedGroup}
947
+ onItemClick={() => setShowDetails(true)}
948
+ />
949
+
950
+ // Group details panel uses real kit components:
951
+ {showDetails && selectedGroup && (
952
+ <div style={{ width: "320px", borderLeft: "1px solid #eee" }}>
953
+ {/* CometChatGroupMembers is a real kit component */}
954
+ <CometChatGroupMembers
955
+ group={selectedGroup}
956
+ onItemClick={(member) => {
957
+ // Switch to 1:1 chat with this member
958
+ }}
959
+ />
960
+ {/* CometChatBannedMembers is a real kit component */}
961
+ </div>
962
+ )}
963
+ ```
964
+
965
+ **Important:** `CometChatGroupMembers` requires the `group` prop (it's the only required prop). The component handles member listing, search, scope changes, kick, and ban actions internally.
966
+
967
+ ---
968
+
969
+ ### Calls integration
970
+
971
+ Add voice/video calling to your message view, plus incoming call handling at the app root.
972
+
973
+ ```tsx
974
+ // 1. Add call buttons to the message header:
975
+ <CometChatMessageHeader
976
+ user={selectedUser}
977
+ auxiliaryButtonView={<CometChatCallButtons user={selectedUser} />}
978
+ />
979
+
980
+ // 2. Mount incoming call handler at the app root (outside any route):
981
+ function App() {
982
+ return (
983
+ <>
984
+ <CometChatIncomingCall />
985
+ <Routes>
986
+ {/* your routes */}
987
+ </Routes>
988
+ </>
989
+ );
990
+ }
991
+ ```
992
+
993
+ `CometChatIncomingCall` must be mounted at the top level so it can show the incoming call overlay regardless of which page the user is on. `CometChatOutgoingCall` and `CometChatOngoingCall` are automatically rendered by the call flow.