files/en-us/web/api/rtcpeerconnection/connectionstate/index.md
{{APIRef("WebRTC")}}
The connectionState read-only property of the {{domxref("RTCPeerConnection")}} interface indicates the current state of the peer connection by returning one of the following string values: new, connecting, connected, disconnected, failed, or closed.
This state essentially represents the aggregate state of all ICE transports (which are of type {{domxref("RTCIceTransport")}} or {{domxref("RTCDtlsTransport")}}) being used by the connection.
When this property's value changes, a {{domxref("RTCPeerConnection.connectionstatechange_event", "connectionstatechange")}} event is sent to the {{domxref("RTCPeerConnection")}} instance.
A string representing the current state of the connection. This can take on of the following values:
new
new state, and none of them are in one of the following states: connecting, checking, failed, disconnected, or all of the connection's transports are in the closed state.connecting
checking or connected, and no transports are in the failed state.connected
connected or completed) or is closed (state closed);
in addition, at least one transport is either connected or completed.disconnected
disconnected state and none of the other transports are in the states: failed, connecting, or checking.failed
failed state.closed
const peerConnection = new RTCPeerConnection(configuration);
// …
const connectionState = peerConnection.connectionState;
{{Specifications}}
{{Compat}}