This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The RTCDataChannelEvent() constructor creates a new RTCDataChannelEvent.

You will rarely if ever construct an RTCDataChannelEvent by hand; these events are normally created and sent by the WebRTC layer itself.


 var event = new RTCDataChannelEvent(type, rtcDataChannelEventInit);


A DOMString which specifies the name of the event. There is only one type of RTCDataChannelEvent, so this will always be "datachannel".
A RTCDataChannelEventInit dictionary, which has following fields:
  • "channel" of type RTCDataChannel, representing the data channel being concerned by the event.
  • "bubbles", optional, inherited from EventInit. Indicates if the event must bubble or not. Default is false.
  • "cancelable", optional, inherited from EventInit. Indicates if the event can be canceled or not. Default is false.


A new RTCDataChannelEvent configured as specified.


In this example, a new datachannel event is created. dc is a data channel which already exists.

var event = new RTCDataChannelEvent("datachannel", {"channel": dc});


Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCDataChannelEvent' in that specification.
Candidate Recommendation Initial specification.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
RTCDataChannelEvent() constructorChrome Full support 57Edge Full support ≤79Firefox Full support 22IE No support NoOpera Full support 44Safari ? WebView Android Full support 57Chrome Android Full support 57Firefox Android Full support 22Opera Android Full support 43Safari iOS ? Samsung Internet Android Full support 7.0


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also