Skip to main content

Goal

By the end of this guide you will have a chat screen where users can pin a message so it’s highlighted for everyone in the conversation, open a panel of all pinned messages, and save a message privately to their own list — with a dedicated “Saved” screen to review saves across every conversation. Pin and save are two separate concepts:

Prerequisites

  • Completed the Integration Guide
  • A running CometChatProvider setup with valid credentials
  • An existing chat screen using CometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer
  • Pin messages and Save messages enabled for your app through the features.ux.messages.pinned.enabled and features.ux.messages.saved.enabled app settings. See Core Features → Pin & Save.
The pin/unpin and save/unsave options only appear in the message options menu when the corresponding feature is enabled for your app. The UI Kit reads that setting at login, so no extra wiring is needed to show or hide the options.

Step 1: The Message Options

Once the features are enabled, CometChatMessageList automatically adds Pin, Unpin, Save, and Unsave to the message options menu — no props required. You only need the hide* props if you want to remove one: File: ChatScreen.tsx
The Pin/Unpin option is shown to every member — the UI Kit does not gate it by role. Permission is enforced by the server: if a member isn’t allowed to pin (or unpin) in that conversation, the action is rejected and the UI Kit shows a permission toast (localizable via the action_permission_denied key). Saving is per-user and always available. See the Message List options.

Step 2: Open the Pinned Messages Panel

CometChatMessageHeader exposes a pinned-messages action in its overflow menu. Wire onPinnedMessagesClicked to show CometChatPinnedMessages, scoped to the same user/group. File: ChatScreen.tsx
The pinned-messages action only appears in the header when pinning is enabled (the features.ux.messages.pinned.enabled app setting) and you provide onPinnedMessagesClicked. Use hidePinnedMessagesOption on the header to remove it explicitly.

Step 3: Add a “Saved” Screen

Saves are personal and span every conversation, so CometChatSavedMessages takes no user/group and is not opened from a built-in menu. Mount it wherever your app wants a “Saved” destination — a route, a tab, or a panel toggled from your own button. File: AppShell.tsx

Step 4: Pinned & Saved Indicators

Pinned and saved messages render an indicator on the bubble in the main message list, so users can see a message’s status inline. This is automatic — no configuration needed. See Message Bubble → Pinned & Saved indicators.
Live Preview — a bubble carrying both the pinned and saved indicators.Open in Storybook ↗

Step 5: Limits

Your app can cap how many messages may be pinned or saved. These caps are configured as app settings in the dashboard: When a user hits a cap, the UI Kit shows a toast explaining the limit — you don’t need to handle the error yourself. The kit reads these settings at login so the toast can name the exact cap.

Custom UI

The built-in components handle pin and save end to end — reach for this section only if you’re building your own message or conversation UI and want the same behavior. Drive pin/save directly with the SDK calls, then publish an optimistic UI event so the built-in surfaces (the message list, the Pinned and Saved panels, the conversation list) stay in sync with your action: For a conversation, with/type are the peer’s UID (or the group’s GUID) and "user" / "group" — not the conversationId. Read the current state off the message or conversation object: isPinned() and isSaved() return booleans, and getPinnedAt() / getPinnedBy() / getSavedAt() return the details (or undefined when unset). The presence of the value is what “pinned” / “saved” means, so branch on isPinned() / isSaved() rather than comparing timestamps.
Permission and the per-app caps are enforced by the server, so wrap the calls in try/catch and surface a message on rejection — see Limits and the permission behavior in Step 1. Publishing the ui: events above is what keeps the message list and the Pinned/Saved panels in step with your custom action. For the full event list, see the Event System.

Complete Example

File: App.tsx

Next Steps