What is a Plugin?
A plugin owns one or more message types. It tells the UI Kit:- How to render the message as a bubble in the message list
- What context menu options to show when a user hovers/long-presses a message
- What preview text to display in the Conversations list subtitle
Where Plugins Are Used
| Location | Plugin Method | What it does |
|---|---|---|
| Message List | renderBubble() | Renders the bubble content (text, image grid, poll, etc.) |
| Message List | getOptions() | Provides context menu items (reply, edit, delete, copy, react) |
| Conversations List | getLastMessagePreview() | Returns subtitle text (”📷 Photo”, “You: Hello”, ”🎥 Video”) |
| Message Bubble | renderHeaderView(), renderFooterView(), etc. | Customizes bubble regions beyond content |
Default Plugins
These plugins are included automatically — no configuration needed:| Plugin | Message Type | What it renders |
|---|---|---|
| Text | text | Formatted text with mentions, URLs, markdown |
| Image | image | Image grid with captions, click-to-fullscreen |
| Video | video | Video player with thumbnail |
| File | file | File card with download button |
| Audio | audio | Waveform audio player |
| Polls | extension_poll | Poll creation + voting bubble |
| Stickers | extension_sticker | Sticker image bubble |
| Collaborative Document | extension_document | Document collaboration link |
| Collaborative Whiteboard | extension_whiteboard | Whiteboard collaboration link |
| Group Action | groupMember | ”User joined”, “User left” system messages |
| Call Action | audio, video (call category) | “Missed call”, “Call ended” system messages |
| Delete | Any (deleted) | “This message was deleted” placeholder |
How Plugin Resolution Works
When the UI Kit needs to render a message, it asks the Plugin Registry to find the right plugin:- If the message is deleted (
getDeletedAt() !== null), the Delete plugin handles it - Otherwise, the registry finds the first plugin whose
messageTypesincludes the message’s type AND whosemessageCategoriesincludes the message’s category - First match wins — plugin order matters
Adding Plugins
Default plugins are always included. To add extra plugins (like AI), pass them via theplugins prop on CometChatProvider:
Creating a Custom Plugin
Implement theCometChatMessagePlugin interface. Here’s a minimal “location” message plugin:
Plugin Interface Reference
Plugin Context
Thecontext object passed to every plugin method:
| Field | Type | Description |
|---|---|---|
loggedInUser | CometChat.User | The currently logged-in user |
group | CometChat.Group | undefined | The group (if group chat) |
alignment | "left" | "right" | "center" | Bubble alignment |
theme | "light" | "dark" | Current theme |
getLocalizedString | (key: string) => string | Localization function |
onDeleteMessage | (msg) => void | Delete a message |
onEditMessage | (msg) => void | Enter edit mode |
onReplyMessage | (msg) => void | Set reply-to target |
onThreadClick | (msg) => void | Open thread view |
onReactToMessage | (msg) => void | Open emoji picker |
onMessageInfo | (msg) => void | Open message info panel |
onMarkAsUnread | (msg) => void | Mark as unread |
onFlagMessage | (msg) => void | Open flag/report dialog |
showToast | (text) => void | Show a toast notification |
getTextFormatters | () => Formatter[] | Get text formatters for caption rendering |
publish | (event) => void | Publish a UI event |
Next Steps
Text Plugin
Text rendering, mentions, markdown, URLs
Image Plugin
Image grid, captions, fullscreen viewer
Custom Plugin
Build your own plugin from scratch
Text Formatters
URL, mentions, markdown, and custom formatters