Skip to content

Get Peer Connection

Web only

This method is only available in the JavaScript/TypeScript SDK.

Returns the underlying RTCPeerConnection for an active call leg. Use this to inspect or interact with the WebRTC peer connection after a call has been established.

Signature

const pc = client.getPeerConnection(callId);

Parameters

ParameterTypeRequiredDescription
callIdstringYesThe identifier of the active call

Return Type

Returns RTCPeerConnection | undefined. Returns undefined if no peer connection exists for the given callId (e.g. the call has not yet been established or has already ended).

Usage Example

const pc = client.getPeerConnection('callId');
if (pc) {
  console.log(`Connection state: ${pc.connectionState}`);
}

Notes

  • The peer connection is available from the point the call is answered/connected
  • For the earliest possible access to the peer connection — before ICE gathering begins — use the onPeerConnectionCreated event instead

Built with VitePress.