W3cubDocs

/Web APIs

RTCIceServer: username property

The RTCIceServer dictionary's username property is a string which specifies the username to use when authenticating with the ICE server being described.

Note: This value is used when the RTCIceServer describes a TURN server.

Syntax

js

const iceServer = {
  // ...
  username: someUsername,
  // ...
};

const username = iceServer.username;

iceServer.username = newUsername;

Example

This example creates a new RTCPeerConnection which will use a TURN server at turnserver.example.org to negotiate connections. Logging into the TURN server will use the username "webrtc" and the creative password "turnpassword".

js

myPeerConnection = new RTCPeerConnection({
  iceServers: [
    {
      urls: "turn:turnserver.example.org", // A TURN server
      username: "webrtc",
      credential: "turnpassword",
    },
  ],
});

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
username 29 ≤79 23 No 16 11 No 29 24 16 11 2.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer/username