Your first message
After a successful connection, you can send a 1:1 realtime message to another user. This hub explains the concept; language pages have runnable code.
What you are building
A minimal flow with two logical users:
user-alice (your SDK) user-bob (another client)
β β
β send({ receiverId: "user-bob", ... }) β
βββββββββββββββββββββββββββββββββββββββββββΊβ
β β
ββββββββββββββββββββββββββββββββββββββββββββ€
β onMessage on bob's client βBoth users connect with the same appId but different userId values. Messages route by senderId and receiverId.
Requirements
transport: "ws"β realtime send/receive uses WebSocketconnect()completed βisConnected === trueReceiver exists conceptually β the receiver does not need to be online; DNotifier delivers when they connect (subject to plan and app rules)
The send() call
All SDKs expose a similar send() shape:
senderId
Must match the connecting user's id (your userId)
receiverId
Target user's id (single recipient)
data
JSON-serializable payload β typically { type: "text", text: "..." }
saveHistory
Optional; default true β persist for chat history APIs
Example payload:
Use any type string your app understands (text, image, audio, doc, custom types).
Receiving messages
Incoming messages arrive on the onMessage callback registered at construction time. Each message has:
metadataβ sender, timestamp, id, typepayloadβ body with helpers liketoJSON()
See Understanding messages for the full model.
Language guides
Test with two clients
To see end-to-end delivery:
Run two terminal processes (or two browser tabs)
Connect as
user-alicein one anduser-bobin the otherSend from alice to bob and watch bob's
onMessagefire
Next steps
Understanding messages β Metadata, payload, and types
Realtime communication overview β Deeper messaging patterns
Chat overview β Building chat on top of realtime
Last updated