SIP.js is a free, open source messaging & event streaming project written in TypeScript and released under MIT. It has 2,096 GitHub stars, 728 forks and 97 open issues, and was last pushed 3 months ago. On this registry it ranks #10 of 14 tracked projects in Messaging & Event Streaming, with 5 head-to-head comparisons available.

What is SIP.js?

SIP.js is an MIT-licensed TypeScript library that gives web applications a JavaScript signaling stack for SIP over WebSocket, so browsers can place and receive real-time audio and video sessions through WebRTC.

What it is

SIP.js is a JavaScript signaling library that brings the Session Initiation Protocol into web applications. It is written in TypeScript, ships as the sip.js npm package and as a UMD bundle, and runs in all major web browsers. The project lives in the web real-time communications ecosystem, alongside WebRTC and the VoIP servers that speak SIP. The repository is tagged javascript, nodejs, sip, sipjs, typescript, voip and webrtc.

The concrete problem is browser reach into SIP infrastructure. Browsers cannot open the raw TCP or UDP sockets that classic SIP depends on, so a web client cannot register with, or place a call against, a SIP server on its own. SIP.js solves this by implementing SIP over WebSocket as specified in RFC 7118, and by binding that signaling to WebRTC media. It replaces the hand-written signaling glue, or the server-side back-to-back user agent, that a team would otherwise need to bridge a browser front end to a standards-compliant server such as Asterisk or FreeSWITCH.

Key capabilities

  • Creates real-time peer-to-peer audio and video sessions through WebRTC.
  • Carries SIP over WebSocket per RFC 7118, so signaling runs inside the browser.
  • Sends instant messages and views presence.
  • Supports early media, hold and transfers.
  • Sends DTMF either as RFC 2833 or as SIP INFO.
  • Shares the screen or desktop.
  • Exposes two API levels: the SimpleUser class documented in docs/simple-user.md, and a full API framework built on UserAgent, Inviter and SessionState, documented in docs/api.md.

Who uses it and how

  • Web teams adding calling to an existing browser front end, using SimpleUser with an aor, a wss:// server URL and media constraints to connect and place a call in a few lines.
  • Applications needing finer session control, using the full framework: construct a UserAgent, call start(), build an Inviter against a target URI, and react to transitions through inviter.stateChange.addListener.
  • Deployments that already run a standards-compliant SIP server such as Asterisk or FreeSWITCH, where SIP.js acts as the browser-side signaling client.
  • Evaluators and integrators, who can run the browser demonstrations listed in ./demo/README.md or the live demo on sipjs.com.

Getting started

Install the Node module with npm install sip.js, or take the UMD bundle from sipjs.com/download or the jsDelivr CDN. To build and test from a clone, run npm install, then npm run build-and-test.

How it compares

No list of paid products it replaces is supplied here, and the facts name no directly comparable signaling library. Asterisk and FreeSWITCH appear only as SIP servers that SIP.js is compatible with, not as alternatives to it. Within this registry it stands alone.

When to use it — and when not to

SIP.js is a client-side signaling library, not a server: anyone self-hosting it still has to operate a SIP server such as Asterisk or FreeSWITCH, a WebSocket endpoint and the media path, none of which the package provides. Skip it if the goal is a hosted calling service that runs no infrastructure, or if the application needs a native, non-browser SIP stack. The repository carries 97 open issues, and the README excerpt is largely usage samples, so the migration guides and API reference under ./docs/README.md, plus the Google Group, are the places to check before committing.

project readme (upstream, from github) — read inline

SIP.js Logo

Build Status npm version

SIP Library for JavaScript

  • Create real-time peer-to-peer audio and video sessions via WebRTC
  • Utilize SIP in your web application via SIP over WebSocket
  • Send instant messages and view presence
  • Support early media, hold and transfers
  • Send DTMF RFC 2833 or SIP INFO
  • Share your screen or desktop
  • Written in TypeScript
  • Runs in all major web browsers
  • Compatible with standards compliant servers including Asterisk and FreeSWITCH

Demo

Want see it in action? The project website, sipjs.com, has a live demo.

Looking for code to get started with? This repository includes demonstrations which run in a web browser.

Usage

To place a SIP call, either utilize the SimpleUser class...

import { Web } from "sip.js";

// Helper function to get an HTML audio element
function getAudioElement(id: string): HTMLAudioElement {
  const el = document.getElementById(id);
  if (!(el instanceof HTMLAudioElement)) {
    throw new Error(`Element "${id}" not found or not an audio element.`);
  }
  return el;
}

// Options for SimpleUser
const options: Web.SimpleUserOptions = {
  aor: "sip:[email protected]", // caller
  media: {
    constraints: { audio: true, video: false }, // audio only call
    remote: { audio: getAudioElement("remoteAudio") } // play remote audio
  }
};

// WebSocket server to connect with
const server = "wss://sip.example.com";

// Construct a SimpleUser instance
const simpleUser = new Web.SimpleUser(server, options);

// Connect to server and place call
simpleUser.connect()
  .then(() => simpleUser.call("sip:[email protected]"))
  .catch((error: Error) => {
    // Call failed
  });

Or, alternatively, use the full API framework...

import { Inviter, SessionState, UserAgent } from "sip.js";

// Create user agent instance (caller)
const userAgent = new UserAgent({
  uri: UserAgent.makeURI("sip:[email protected]"),
  transportOptions: {
    server: "wss://sip.example.com"
  },
});

// Connect the user agent
userAgent.start().then(() => {

  // Set target destination (callee)
  const target = UserAgent.makeURI("sip:[email protected]");
  if (!target) {
    throw new Error("Failed to create target URI.");
  }

  // Create a user agent client to establish a session
  const inviter = new Inviter(userAgent, target, {
    sessionDescriptionHandlerOptions: {
      constraints: { audio: true, video: false }
    }
  });

  // Handle outgoing session state changes
  inviter.stateChange.addListener((newState) => {
    switch (newState) {
      case SessionState.Establishing:
        // Session is establishing
        break;
      case SessionState.Established:
        // Session has been established
        break;
      case SessionState.Terminated:
        // Session has terminated
        break;
      default:
        break;
    }
  });

  // Send initial INVITE request
  inviter.invite()
    .then(() => {
      // INVITE sent
    })
    .catch((error: Error) => {
      // INVITE did not send
    });

});

Installation

Node module

npm install sip.js

UMD bundle

Building, Development and Testing

Clone this repository, then...

npm install
npm run build-and-test

For more info please see the Documentation.

Support

  • For migration guides and API reference please see the Documentation.
  • For bug reports and feature requests please open a GitHub Issue.
  • For questions or usage problems please use the Google Group.
  • For more information see the project website at SIPjs.com.

Frequently asked questions

Is SIP.js free to use?

SIP.js is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does SIP.js do?

A simple, intuitive, and powerful JavaScript signaling library

What is SIP.js written in?

SIP.js is primarily written in TypeScript. Its source is publicly available at https://github.com/onsip/SIP.js, and it has 2,096 GitHub stars.