RTCPeerConnection: signalingstatechange event

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

A signalingstatechange event is sent to an RTCPeerConnection to notify it that its signaling state, as indicated by the signalingState property, has changed.

This event is not cancelable and does not bubble.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js
addEventListener("signalingstatechange", (event) => {});

onsignalingstatechange = (event) => {};

Event type

A generic Event.

Examples

Given an RTCPeerConnection, pc, and an updateStatus() function that presents status information to the user, this code sets up an event handler to let the user know when the ICE negotiation process finishes up.

js
pc.addEventListener(
  "signalingstatechange",
  (ev) => {
    switch (pc.signalingState) {
      case "stable":
        updateStatus("ICE negotiation complete");
        break;
    }
  },
  false,
);

Using onsignalingstatechange, it looks like this:

js
pc.onsignalingstatechange = (ev) => {
  switch (pc.signalingState) {
    case "stable":
      updateStatus("ICE negotiation complete");
      break;
  }
};

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# event-signalingstatechange

Browser compatibility

BCD tables only load in the browser

See also