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

The RTCPeerConnection.onnegotiationneeded property is an EventHandler which specifies a function which is called to handle the negotiationneeded event when it occurs on an RTCPeerConnection instance. This event is fired when a change has occurred which requires session negotiation.

The most common scenario in which this will happen is at the beginning of a connection. After using createOffer() to create a new offer and setting it as the description of the local end of the connection by calling setLocalDescription(), the browser will, when it's ready, fire negotiationneeded to let you know it's ready for you to begin negotiating the connection. That's when it's time to send the offer along through the signaling server.


RTCPeerConnection.onnegotiationneeded = eventHandler;


This should be set to a function you provide which is passed a single parameter: an Event object containing the negotiationneeded event. There's no additional information provided in the event; anything you need, you can get by examining the properties of the RTCPeerConnection.


This example, derived from the example in Signaling and video calling, establishes a handler for negotiationneeded events to handle creating an offer, configuring the local end of the connection, and sending the offer to the remote peer.

pc.onnegotiationneeded = function() {
  pc.createOffer().then(function(offer) {
    return pc.setLocalDescription(offer);
  .then(function() {
      // Send the offer to the remote peer through the signaling server

First, it creates the offer by calling createOffer(). When that succeeds, the offer is passed into setLocalDescription() to set the local description for the connection. Once that's succeeded in turn, the offer can be sent to the signaling server for delivery to the remote peer.


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

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support56 Yes22 ?


37 — 43

FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support5656 Yes44


37 — 43

? ?

1. Promise based version.

See also

Document Tags and Contributors

 Contributors to this page: fscholz, jpmedley, abbycar, Sheppy, Jib, teoli
 Last updated by: fscholz,