Last updated: April 7, 2026

PeerConnection (RTCPeerConnection) is the core JavaScript API in WebRTC. It represents a connection between the local device and a remote peer, handling the full lifecycle of a WebRTC session including SDP negotiation, ICE NAT traversal, and DTLS/SRTP encrypted media exchange.

PeerConnection lifecycle

  1. Creation: new RTCPeerConnection(config) – configuration includes STUN/TURN server URLs
  2. Adding media: addTrack() or addTransceiver() to attach audio/video tracks
  3. SDP negotiation: The JSEP offer/answer exchange via createOffer(), setLocalDescription(), setRemoteDescription(), createAnswer()
  4. ICE connectivity: Candidates are gathered and exchanged, connectivity checks run
  5. Connected: Media flows between peers via encrypted SRTP
  6. Monitoring: getStats() provides real-time quality metrics
  7. Closure: close() terminates the session

Key features

  • Unified Plan SDP: Each media track gets its own m= line in the SDP
  • Trickle ICE: ICE candidates are sent incrementally for faster connection setup
  • Data Channel: Created via createDataChannel() on the PeerConnection
  • BUNDLE: All media multiplexed over a single transport connection

PeerConnection is defined by the W3C WebRTC specification and implemented in all modern browsers via libWebRTC.

Additional reading

Tags: API

Looking to learn more about WebRTC? 

Check my WebRTC training courses

About WebRTC Glossary

The WebRTC Glossary is an ongoing project where users can learn more about WebRTC related terms. It is maintained by Tsahi Levent-Levi of BlogGeek.me.