Overview
Custom plugins let you handle any message type with your own rendering logic. This guide walks through building a complete “Location” plugin that:- Renders a map preview bubble
- Provides context menu options
- Shows a preview in the conversations list
Step 1: Define the Plugin
Create a file for your plugin that implementsCometChatMessagePlugin:
src/plugins/LocationPlugin.tsx
Step 2: Register the Plugin
Pass your plugin toCometChatProvider:
src/App.tsx
"location" messages.
Step 3: Send a Location Message
Use the CometChat SDK to send a custom message with type"location":
Step 4: Style the Bubble
Add CSS for your bubble:src/plugins/LocationPlugin.css
Plugin Interface Quick Reference
Tips
- Lazy-load heavy components — use
React.lazy()+Suspensefor bubble components that import large libraries - Use
context.getLocalizedString— for any user-facing text in options or bubbles - Return
[]fromgetOptions— for system messages that shouldn’t have a context menu - Keep
getLastMessagePreviewshort — max ~100 characters, plain text only (no HTML) - Test with
messageTypesarray — a single plugin can handle multiple types (like the Call Action plugin handles bothaudioandvideoin thecallcategory)