This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
The RTCDataChannelEvent interface represents an event related to a specific RTCDataChannel.
RTCDataChannelEvent()Creates a new RTCDataChannelEvent.
Also inherits properties from Event.
channel Read only
Returns the RTCDataChannel associated with the event.
In this example, the datachannel event handler is set up to save the data channel reference and set up handlers for the events which need to be monitored. The channel property provides the RTCDataChannel representing the connection to the other peer.
pc.ondatachannel = (event) => {
inboundDataChannel = event.channel;
inboundDataChannel.onmessage = handleIncomingMessage;
inboundDataChannel.onopen = handleChannelOpen;
inboundDataChannel.onclose = handleChannelClose;
};
See A simple RTCDataChannel sample for another, more complete, example of how to use data channels.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
RTCDataChannelEvent |
56 | 79 | 22 | 43 | 11 | 56 | 24 | 43 | 11 | 7.0 | 56 | 11 |
RTCDataChannelEvent |
24 | 79 | 22 | ≤15 | 11 | 25 | 24 | ≤14 | 11 | 1.5 | 4.4 | 11 |
channel |
24 | 79 | 22 | ≤15 | 11 | 25 | 24 | ≤14 | 11 | 1.5 | 4.4 | 11 |
RTCDataChannelRTCPeerConnection (the target interface for datachannel events)
© 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/RTCDataChannelEvent