Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Voice JavaScript SDK: Twilio in the browser


(information)

Info

You're viewing the documentation for the 2.X version of the Voice JavaScript SDK. View the Migration Guide to learn how to migrate from 1.X to 2.X or view the 1.x-specific documentation.

(information)

Info

The Twilio Client JavaScript SDK has been renamed to Twilio Voice JavaScript SDK.

(warning)

Warning

When using the Voice Javascript SDK with Twilio Regions, please make sure the SDK version is updated to at least 2.1.0


Overview

overview page anchor

The Twilio Voice JavaScript SDK allows you to make voice calls to and from a web browser and a Twilio TwiML Voice Application. This means you can open inbound and outbound audio connections to Twilio for building softphones, walkie-talkies, conference calls, click-to-talk systems, and more, all from the browser.

(information)

Info

Want to get started right away? Jump right in with one of our Voice JavaScript SDK Quickstarts.

(information)

You set up your device and establish a connection to Twilio. Audio from your device's microphone is sent to Twilio, and Twilio sends back audio which is played through your device's speakers, like on a normal phone call. The key difference is that with Twilio Voice JavaScript SDK, your "phone" is a Twilio.Device, a "soft device" that provides connections into Twilio.

Your application connects to Twilio, Twilio sends a webhook to your back end to get TwiML instructions.

_10
npm install @twilio/voice-sdk --save

Using this method, you can import the Voice SDK using ES Module or TypeScript syntax:


_10
import { Device } from '@twilio/voice-sdk';

Or using CommonJS:


_10
const Device = require('@twilio/voice-sdk').Device;

As of 2.0, the Twilio Voice SDK is no longer hosted via CDN.

Although we recommend using npm to add the Voice SDK as a dependency, you can also get the Twilio Voice SDK code from GitHub and include it in your project directly. To do so, navigate to "Releases"(link takes you to an external page) and find the most recent release, or the particular release version you'd like to use.

(warning)

Warning

Releases tagged with "-rc" are "Release Candidate" versions and are still being tested. Unless you specifically know that you want to use a release candidate version, you should not use a release with "-rc" in the name.

Download either the zip or the tar.gz and then extract the files. For example, if you downloaded the tarball for the 2.0.0 release, you could then extract the files with the tar command:


_10
tar -xvzf twilio-voice.js-2.0.0.tar.gz
_10
cd twilio-voice.js-2.0.0

Once you've extracted the folder, the twilio.js and twilio.min.js files that you can include in your project will be in the /dist directory. twilio.min.js is the minified version of the code.

You can copy either the twilio.js or the twilio.min.js file into your project and then provide a link to it in your html. For example:


_10
<script type="text/javascript" src="twilio.min.js"></script>

Using this method, you can access the SDK through the browser global:


_10
const Device = Twilio.Device;


The following table indicates the browsers supported by the Twilio Voice JavaScript SDK. We support the most recent (N) and the two previous (N-2) versions of these browsers unless otherwise indicated.

ChromeFirefoxSafari*Edge**
Android
iOS
Linux
macOS
Windows

* WebRTC support in Safari started with Safari version 11.

** We support Chromium-based Edge only. Legacy Edge(link takes you to an external page) isn't supported. See this advisory(link takes you to an external page) for more details.

(information)

Info

Mobile browsers lack the ability to receive or maintain call connectivity whilst in the background and they do not allow GSM call interruption handling. These lead to poor user experience. To create the best user experience, Twilio recommends understanding these limitations when creating mobile Voice Applications. Twilio also recommends evaluating the iOS and Android SDKs for creating mobile Voice Applications.

Twilio Voice JavaScript SDK is also supported on the latest Electron(link takes you to an external page) version

ChannelType
SignalingTLS (Secure Web Socket)
MediaDTLS-SRTP (AES_CM_128_HMAC_SHA1_80)

As of version 1.3, Twilio Voice JavaScript SDK (formerly known as Twilio Client JS SDK) has been strictly following semantic versioning(link takes you to an external page): minor-level updates only contain feature updates and are completely backward compatible with 1.3.0 and newer.

Support for twilio.js 1.1 and 1.2 ceased on February 14, 2018. If you are still using either of these versions, please use the Migration Guide to upgrade to the latest version.


Rate this page: