Browse SDKs · WASM
SDKsWASM

Create a text message

Create a text message with the WASM SDK.

Copy

A message creation API returns only a pending message object. It does not send the message to the server or trigger a new-message event. createTextMessage() accepts a text string; validate whitespace, length, and content rules in your application first.

const text = input.trim();
if (!text) return;

const { data: message } = await openimsdk.createTextMessage(text);

When the Promise resolves, it returns a pending MessageItem. Next, call sendMessage() with this object; see Send a message for the complete sending flow. After the message is sent successfully, use clientMsgID to find and update the local pending message.