Skip to main content
Quick Reference — Send a transient message:
let data = { "LIVE_REACTION": "heart" };
let transientMessage = new CometChat.TransientMessage("RECEIVER_ID", CometChat.RECEIVER_TYPE.USER, data);
CometChat.sendTransientMessage(transientMessage);
Available via: SDK | REST API | UI Kits
Transient messages are messages that are sent in real-time only and are not saved or tracked anywhere. The receiver of the message will only receive the message if he is online and these messages cannot be retrieved later.

Send a Transient Message

You can use the sendTransientMessage() method to send a transient message to a user or in a group. The receiver will receive this information in the onTransientMessageReceived() method of the MessageListener class. In order to send the transient message, you need to use the TransientMessage class.
let receiverId = "UID";
let receiverType = CometChat.RECEIVER_TYPE.USER;
let data = { "LIVE_REACTION": "heart" };

let transientMessage = new CometChat.TransientMessage(receiverId, receiverType, data);
CometChat.sendTransientMessage(transientMessage);

Real-time Transient Messages

In other words, as a recipient, how do I know when someone sends a transient message? You will receive the transient message in the onTransientMessageReceived() method of the registered MessageListener class.
let listenerId = "UNIQUE_LITENER_ID";

CometChat.addMessageListener(
listenerId,
new CometChat.MessageListener({
  onTransientMessageReceived: transientMessage => {
    console.log('transient message received', transientMessage);
  },
})
);
Listener Cleanup — Always remove your message listeners when the component unmounts to prevent memory leaks and unexpected behavior. Use CometChat.removeMessageListener("UNIQUE_LITENER_ID") in your cleanup logic (e.g., inside a useEffect return function or componentWillUnmount).
The TransientMessage class consists of the below parameters:
ParameterInformation
senderAn object of the User class holding all the information. related to the sender of the transient message.
receiverIdUnique Id of the receiver. This can be the Id of the group or the user the transient message is sent to.
receiverTypeThe type of the receiver - CometChat.RECEIVER_TYPE.USER or CometChat.RECEIVER_TYPE.GROUP
dataA JSONObject to provide data.
  • Use transient messages for ephemeral interactions only — Since transient messages are not stored, they are ideal for features like live reactions, presence pings, or real-time indicators that don’t need to persist.
  • Keep the data payload small — Transient messages are designed for lightweight, real-time signals. Avoid sending large JSON objects in the data field.
  • Use unique listener IDs — Each screen or component that registers a MessageListener should use a distinct listenerId to avoid conflicts with other listeners.
  • Confirm the receiver is online — Transient messages are only delivered to online users. If guaranteed delivery is required, use a regular message instead.
  • Pair with typing indicators for richer UX — Combine transient messages with typing indicators to build expressive, real-time chat experiences.
  • Recipient not receiving transient messages — Verify that the recipient is online and has registered a MessageListener with the onTransientMessageReceived callback before the sender dispatches the message.
  • Listener not firing — Confirm that the listenerId used in addMessageListener is unique and that the listener has not been removed prematurely.
  • Messages not arriving in groups — Make sure you are using CometChat.RECEIVER_TYPE.GROUP with the correct group ID (GUID), not a user ID.
  • Cannot retrieve transient messages later — This is expected behavior. Transient messages are never stored. If you need message persistence, use send a message instead.
  • Data field appears empty on the receiver side — Ensure you are passing a valid JSON object to the data parameter when constructing the TransientMessage instance.

Next Steps