Messaging & Data

Not every connection carries audio or video. The RTCDataChannel moves arbitrary data between peers: text, JSON, binary buffers, game state, anything an application needs. It is the part of WebRTC that has nothing to do with media.

What it enables

A direct, encrypted channel for application data with no server in the path. Chat messages, multiplayer game state, collaborative cursors, and telemetry all travel peer-to-peer. Because the data does not transit a server, latency drops and the application provider never sees the payload.

A single connection can carry several channels at once, each with its own settings.

How it works (high level)

The data channel rides on the same connection that media would use. After the offer/answer exchange and ICE find a path, the channel opens. Under the hood it runs SCTP over the encrypted DTLS transport, which is why every channel is private by default.

Peer ARTCDataChannel Peer BRTCDataChannel reliable / ordered unreliable / unordered ONE SCTP PIPE, TWO MODES

Delivery is configurable per channel. The default is reliable and ordered, like TCP: every message arrives, in the order it was sent. An application can instead choose unordered delivery, or limit retransmissions so a late message is dropped rather than resent. Fast-moving game state often wants the unreliable mode, where a stale position update is worthless and waiting for it would only add lag.

Sending is a single send call that accepts a string or a binary buffer. Receiving is an onmessage event. The channel exposes its readyState, so an application sends only when the state is open.

Large or rapid sends need care. The channel buffers outgoing data, and pushing faster than the link drains causes the buffer to grow. Applications watch the buffered amount and pause when it climbs, a pattern that matters most for file transfer.

Where it's used

Text chat alongside a call, real-time multiplayer game sync, shared whiteboards and cursors, remote control inputs, and any feature that needs low-latency data without a backend relay.

This site uses data channels for every game: inputs, state, and game-switching control messages all travel over the channel.

Open the messaging deep dives