CometChatSoundManager handles audio notifications for chat events. It plays sounds when messages are sent/received and when calls are initiated/received. Components use it internally — you don’t need to call it manually unless you want custom behavior.
Individual components accept the same props. When set, they override the global config for that component only.
{/* Override global config for this specific component */}<CometChatConversations disableSoundForMessages={false} customSoundForMessages="/sounds/conversation-alert.mp3"/><CometChatIncomingCall disableSoundForCalls={false} customSoundForCalls="/sounds/incoming-ring.mp3"/>
Components that accept sound props:
Component
Props
CometChatConversations
disableSoundForMessages, customSoundForMessages
CometChatMessageList
disableSoundForMessages, customSoundForMessages
CometChatMessageComposer
disableSoundForMessage, customSoundForMessage
CometChatIncomingCall
disableSoundForCalls, customSoundForCalls
CometChatOutgoingCall
disableSoundForCalls, customSoundForCalls
Component-level props always take precedence over the global config. If a prop is not set on a component, it falls back to the global config value.
import { CometChatSoundManager } from "@cometchat/chat-uikit-react";// Play a custom notification soundCometChatSoundManager.play("incomingMessage", "/sounds/notification.mp3");// Or use convenience methodsCometChatSoundManager.onIncomingMessage("/sounds/notification.mp3");CometChatSoundManager.onOutgoingMessage("/sounds/sent.mp3");
Browsers require user interaction before playing audio. CometChatSoundManager checks navigator.userActivation before attempting playback. If the user hasn’t interacted with the page yet, sounds are silently skipped.
All Audio API usage is guarded behind typeof Audio !== 'undefined' checks. The sound manager is safe to import in server-side rendering environments — it simply no-ops when Audio is unavailable.