This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
* Some parts of this feature may have varying levels of support.
The RTCDataChannel interface represents a network channel which can be used for bidirectional peer-to-peer transfers of arbitrary data. Every data channel is associated with an RTCPeerConnection, and each peer connection can have up to a theoretical maximum of 65,534 data channels (the actual limit may vary from browser to browser).
To create a data channel and ask a remote peer to join you, call the RTCPeerConnection's createDataChannel() method. The peer being invited to exchange data receives a datachannel event (which has type RTCDataChannelEvent) to let it know the data channel has been added to the connection.
RTCDataChannel is a transferable object.
Also inherits properties from EventTarget.
binaryTypeA string specifying the type of object that should be used to represent binary data received on the RTCDataChannel. Values are the same as allowed on the WebSocket.binaryType property: blob if Blob objects are being used, or arraybuffer if ArrayBuffer objects are being used. The default is arraybuffer.
bufferedAmount Read only
Returns the number of bytes of data currently queued to be sent over the data channel.
bufferedAmountLowThresholdSpecifies the number of bytes of buffered outgoing data that is considered "low". The default value is 0.
id Read only
Returns an ID number (between 0 and 65,534) which uniquely identifies the RTCDataChannel.
label Read only
Returns a string that contains a name describing the data channel. These labels are not required to be unique.
maxPacketLifeTime Read only
Returns the amount of time, in milliseconds, the browser is allowed to take to attempt to transmit a message, as set when the data channel was created, or null.
maxRetransmits Read only
Returns the maximum number of times the browser should try to retransmit a message before giving up, as set when the data channel was created, or null, which indicates that there is no maximum.
negotiated Read only
Indicates whether the RTCDataChannel's connection was negotiated by the Web app (true) or by the WebRTC layer (false). The default is false.
ordered Read only
Indicates whether or not the data channel guarantees in-order delivery of messages; the default is true, which indicates that the data channel is indeed ordered.
protocol Read only
Returns a string containing the name of the subprotocol in use. If no protocol was specified when the data channel was created, then this property's value is the empty string ("").
readyState Read only
Returns a string which indicates the state of the data channel's underlying data connection. It can have one of the following values: connecting, open, closing, or closed.
reliable Read only Deprecated Non-standard
Indicates whether or not the data channel is reliable.
Also inherits methods from EventTarget.
close()Closes the RTCDataChannel. Either peer is permitted to call this method to initiate closure of the channel.
send()Sends data across the data channel to the remote peer.
bufferedamountlowSent when the number of bytes of data in the outgoing data buffer falls below the value specified by bufferedAmountLowThreshold.
closeSent when the underlying data transport closes.
closingSent when the underlying data transport is about to start closing.
errorSent when an error occurs on the data channel.
messageSent when a message has been received from the remote peer. The message contents can be found in the event's data property.
openSent when the data channel is first opened, or when an existing data channel's underlying connection re-opens.
The underlying data format is defined by the IEEE specification SDP Offer/Answer Procedures for SCTP over DTLS Transport(RFC 8841). The current format specifies its protocol as either "UDP/DTLS/SCTP" (UDP carrying DTLS carrying SCTP) or "TCP/DTLS/SCTP" (TCP carrying DTLS carrying SCTP). Older browsers may only specify "DTLS/SCTP".
const pc = new RTCPeerConnection();
const dc = pc.createDataChannel("my channel");
dc.onmessage = (event) => {
console.log(`received: ${event.data}`);
};
dc.onopen = () => {
console.log("datachannel open");
};
dc.onclose = () => {
console.log("datachannel close");
};
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
RTCDataChannel |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
binaryType |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
bufferedAmount |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
bufferedAmountLowThreshold |
46 | 79 | 44 | 33 | 11 | 46 | 44 | 33 | 11 | 5.0 | 46 | 11 |
bufferedamountlow_event |
57The default forrtcpMuxPolicy is require. |
79The default forrtcpMuxPolicy is require. |
44 | 44The default forrtcpMuxPolicy is require. |
11 | 57The default forrtcpMuxPolicy is require. |
44 | 43The default forrtcpMuxPolicy is require. |
11 | 7.0The default forrtcpMuxPolicy is require. |
57The default forrtcpMuxPolicy is require. |
11 |
close |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
close_event |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
closing_event |
81 | 81 | No | 68 | 15.4 | 81 | No | 58 | 15.4 | 13.0 | 81 | 15.4 |
error_event |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
id |
30 | 79 | 22 | 17 | 11 | 30 | 24 | 18 | 11 | 2.0 | 4.4 | 11 |
label |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
maxPacketLifeTime |
56 | 79 | 62 | 43 | 11 | 56 | 62 | 43 | 11 | 6.0 | 56 | 11 |
maxRetransmits |
30 | 79 | 62 | 17 | 11 | 30 | 62 | 18 | 11 | 2.0 | 4.4 | 11 |
message_event |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
negotiated |
30 | 79 | 68 | 17 | 11 | 30 | 68 | 18 | 11 | 2.0 | 4.4 | 11 |
open_event |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
ordered |
30 | 79 | 22 | 17 | 11 | 30 | 24 | 18 | 11 | 2.0 | 4.4 | 11 |
priority |
No | No | No | No | 15 | No | No | No | 15 | No | No | 15 |
protocol |
30 | 79 | 22 | 17 | 11 | 30 | 24 | 18 | 11 | 2.0 | 4.4 | 11 |
readyState |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
reliable |
24 | 79 | 22–142 | 15 | No | 25 | 24 | 14 | No | 1.5 | 4.4 | No |
sctp_sdp_21 |
58 | 79 | 63 | 45 | No | 58 | 63 | 43 | No | 7.0 | 58 | No |
send |
24 | 79 | 22 | 15 | 11 | 25 | 24 | 14 | 11 | 1.5 | 4.4 | 11 |
transferable |
130 | 130 | No | 115 | 15 | 130 | No | 86 | 15 | 28.0 | 130 | 15 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel