WebRTC Made Easy for JavaScript Developers

A simple yet powerful JS library that takes care of WebRTC and SIP signaling for you

  • video + audio video + audio highlight

    video + audio

  • message message highlight

    message

Oops!

Looks like your browser can't run this demo.

To get the full experience, download the latest version of Chrome or Firefox

In-browser Video Chat is Now a Breeze

Here's a demo. Start a video chat between Alice and Bob.

Alice's View

Demo user one

Bob's View

Demo user two

Real-Time Messaging with a Dozen Lines of Code

Check it out. Instant message between Alice and Bob.

Bob: No messages yet

Alice's View

Demo user one

Alice: No messages yet

Bob's View

Demo user two

See How It's Done

The code displayed on the right is what powers the selected demo from Alice’s end, although Bob’s code would be very similar. SIP.js allows you to utilize WebRTC’s APIs using just JavaScript. To check out the full code for all three demos, click the button below.

SIP.js makes it easy to utilize WebRTC's APIs and set up SIP communication sessions. In no time at all, you can have two separate users talking to one another. To learn more about the SIP.js API, click the button below.

var domain = 'sipjs.onsip.com';
var aliceURI      = 'alice.' + window.token + '@' + domain;
var aliceName     = 'Alice';

var bobURI        = 'bob.' + window.token + '@' + domain;
var bobName       = 'Bob';

// Function: createSimple
//   creates a SIP.js Simple instance with the given arguments plugged into the
//   configuration. This is a standard Simple instance for WebRTC calls.
//
// Arguments:
//   callerURI: the URI of the caller, aka, the URI that belongs to this user.
//   displayName: what name we should display the user as
//   remoteVideo: the DOM element id of the video for the remote
//   buttonId: the DOM element id of the button for that user
function createSimple(callerURI, displayName, target, remoteVideo, buttonId) {
    var remoteVideoElement = document.getElementById(remoteVideo);
    var button = document.getElementById(buttonId);

    var configuration = {
        media: {
            remote: {
                video: remoteVideoElement,
                // Need audio to be not null to do audio & video instead of just video
                audio: remoteVideoElement
            }
        },
        ua: {
            traceSip: true,
            uri: callerURI,
            displayName: displayName,
            userAgentString: SIP.C.USER_AGENT + " sipjs.com"
        }
    };
    var simple = new SIP.WebRTC.Simple(configuration);

    button.addEventListener('click', function() {
        // No current call up
        if (simple.state === SIP.WebRTC.Simple.C.STATUS_NULL ||
            simple.state === SIP.WebRTC.Simple.C.STATUS_COMPLETED) {
            simple.call(target);
        } else {
            simple.hangup();
        }
    });

    return simple;
}

var aliceSimple = createSimple(aliceURI, aliceName, bobURI, 'video-of-bob', 'alice-video-button');
var domain = 'sipjs.onsip.com';
var aliceURI      = 'alice' + '@' + domain;
var aliceName     = 'Alice';

var bobURI        = 'bob' + '@' + domain;
var bobName       = 'Bob';

// Sets up the chat interface for text messaging
function setUpMessageInterface(simple) {
    // Receive a message and put it in the message display div
    simple.on('message', function (msg) {
        alert(msg.body);
    });
}


var aliceSimple = createSimple(aliceURI, aliceName, bobURI, 'video-of-bob', 'alice-video-button');

setUpMessageInterface(aliceSimple);
aliceSimple.message(bobURI, 'Check out this palindrome: "Now sir, a war is never even. Sir, a war is won."');
See Full Demo Code  Check out the full API 

Don't Want to Bother with the Back End?

If you’d like to identify and locate your user addresses on the Internet so they can participate in RTC sessions, you’ll need SIP servers. You can build your own using open source FreeSWITCH or Asterisk, or you can try out OnSIP - no system setup, modifications, maintenance, or upfront capital required. Sign up for an OnSIP free trial 

Sign up for an OnSIP free trial 

Learn

New to SIP.js? Our guides and docs will have you up and running in a snap.

Connect

Get answers, stay up to date, and become part of the SIP.js community.

Features

  • Register SIP User Agents using the SIP over WebSocket transport
  • Create Audio and Video sessions
  • Send Instant Messages and view Presence
  • Share your screen or desktop
  • Utilize advanced call features such as early media, call hold and resume, and transfers
  • Send DTMF with SIP INFO
  • 100% open source, 100% JavaScript
  • All major browsers supported

Trusted By

Trusted by OnSIP
Trusted by FireRTC
Trusted by RingCentral
Trusted by Twilio
Trusted by Spacivox