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, pass message to sendMessage(). After the message is sent successfully, merge its state by clientMsgID.