# @twilio/voice-sdk

> Twilio's JavaScript Voice SDK

Latest version **2.18.5** (published 2026-09-10) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @twilio/voice-sdk
pnpm add @twilio/voice-sdk
yarn add @twilio/voice-sdk
bun add @twilio/voice-sdk
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.18.5 |
| Published | 2026-09-10 |
| First published | 2021-07-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 12 |
| Dependencies | 5 |
| Unpacked size | 3.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 84 |
| Maintainers | twilio-agent-connect-maintainers, twilio-supply-chain |
| Keywords | twilio, client, sdk, voice, voip |

## Links

- npm: https://www.npmjs.com/package/@twilio/voice-sdk
- Repository: https://github.com/twilio/twilio-voice.js
- Homepage: https://github.com/twilio/twilio-voice.js#readme
- Issues: https://github.com/twilio/twilio-voice.js/issues
- npm.io page: https://npm.io/package/@twilio/voice-sdk

## Dependencies (5)

- [tslib](https://npm.io/package/tslib.md) 2.8.1
- [events](https://npm.io/package/events.md) 3.3.0
- [loglevel](https://npm.io/package/loglevel.md) 1.9.2
- [@types/events](https://npm.io/package/@types/events.md) 3.0.3
- [@twilio/voice-errors](https://npm.io/package/@twilio/voice-errors.md) 1.7.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 2.18.5 (latest) — 2026-09-10
- 2.18.4 — 2026-09-01
- 2.18.3 — 2026-05-11
- 2.18.2 — 2026-04-21
- 2.18.1 — 2026-03-17
- 2.18.0 — 2026-01-05
- 2.17.0 — 2025-12-01
- 2.16.0 — 2025-09-25
- 2.15.0 — 2025-07-14
- 2.14.0 — 2025-06-25
- 2.13.0 — 2025-05-06
- 2.12.4 — 2025-03-12
- 2.12.3 — 2024-12-03
- 2.12.2 — 2024-11-12
- 2.12.1 — 2024-08-30
- … 26 more at https://npm.io/package/@twilio/voice-sdk/versions

## README

@twilio/voice-sdk
=================

[![NPM](https://img.shields.io/npm/v/%40twilio/voice-sdk.svg)](https://www.npmjs.com/package/%40twilio/voice-sdk) [![CI](https://github.com/twilio/twilio-voice.js/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/twilio/twilio-voice.js/actions/workflows/ci.yml)

Twilio's Voice SDK allows you to add real-time voice and PSTN calling to your web apps.

* [API Docs](https://twilio.github.io/twilio-voice.js/index.html)
* [More Docs](https://www.twilio.com/docs/voice/sdks/javascript)
* [Quickstart](https://www.twilio.com/docs/voice/client/javascript/quickstart)
* [Reference Components](https://www.twilio.com/docs/voice/sdks/javascript/reference-components)
* [Changelog](https://github.com/twilio/twilio-voice.js/blob/master/CHANGELOG.md)

### Issues and Support
Please check out our [common issues](COMMON_ISSUES.md) page or file any issues you find here on Github. For general inquiries related to the Voice SDK you can file a support ticket. Please ensure that you are not sharing any [Personally Identifiable Information(PII)](https://www.twilio.com/docs/glossary/what-is-personally-identifiable-information-pii) or sensitive account information (API keys, credentials, etc.) when reporting an issue.

Installation
------------

### NPM

We recommend using `npm` to add the Voice SDK as a dependency.

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

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

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

```

Or using CommonJS:

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

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

### GitHub

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
["Tags"](https://github.com/twilio/twilio-voice.js/tags) and find the most recent release, or
the particular release version you'd like to use.

> **Note:** 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:

```
tar -xvzf twilio-voice.js-2.0.0.tar.gz
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:

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

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

```
const Device = Twilio.Device;
```

Testing
-------

Running unit tests requires no setup aside from installation (above). You can run unit tests via:

```
npm run test:unit
```

Integration tests require some set up:

1. Create a TwiML App with the friendly name `Integration Tests`, using the TwiML code below.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Dial>
    <Client>
      <Identity>{{To}}</Identity>
      <Parameter name="duplicate" value="12345" />
      <Parameter name="duplicate" value="123456" />
      <Parameter name="custom + param" value="我不吃蛋" />
      <Parameter name="foobar" value="some + value" />
      <Parameter name="custom1" value="{{Custom1}}" />
      <Parameter name="custom2" value="{{Custom2}}" />
      <Parameter name="custom3" value="{{Custom3}}" />
    </Client>
  </Dial>
</Response>
```

2. Create a second TwiML App with the friendly name `STIR/SHAKEN`, using the TwiML code below. Be sure to use your Twilio number for the `Dial` verb. 

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Dial callerId="{{CallerId}}">xxxxxxxxxxxxxxxx</Dial>
</Response>
```

3. Make a copy of the `example.env` file with the name `.env` and populate the file with your credentials.

4. Start the relay server

```
npm run test:relay-server
```

5. Integration tests run via Cypress, and can be run via:

```
npm run test:integration:chrome
npm run test:integration:firefox
```

Content Security Policy (CSP)
----------------------------

Use the following policy directives to enable [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) that is compatible with twilio-voice.js.

```
script-src https://media.twiliocdn.com https://sdk.twilio.com
media-src mediastream: https://media.twiliocdn.com https://sdk.twilio.com
connect-src https://eventgw.twilio.com wss://voice-js.roaming.twilio.com https://media.twiliocdn.com https://sdk.twilio.com
```

If you are providing a non-default value for `Device.ConnectOptions.edge` parameter, you need to add the Signaling URI `wss://voice-js.{edgeId}.twilio.com` in your `connect-src` directive where `edgeId` is the `Edge ID` as defined in this [page](https://www.twilio.com/docs/global-infrastructure/edge-locations). See examples below.

**If `Device.ConnectOptions.edge` is `ashburn`**

```
connect-src https://eventgw.twilio.com https://media.twiliocdn.com https://sdk.twilio.com wss://voice-js.ashburn.twilio.com
```

**If `Device.ConnectOptions.edge` is `['ashburn', 'sydney', 'roaming']`**

```
connect-src https://eventgw.twilio.com https://media.twiliocdn.com https://sdk.twilio.com wss://voice-js.ashburn.twilio.com wss://voice-js.sydney.twilio.com wss://voice-js.roaming.twilio.com
```

If you are providing a home region grant into your [Twilio access token](https://www.twilio.com/docs/iam/access-tokens), you need to add the insights endpoint in your `connect-src` directive using `eventgw.{homeRegion}.twilio.com` format. Below is an example if your home region grant is `sg1`.

```
connect-src https://eventgw.sg1.twilio.com wss://voice-js.roaming.twilio.com https://media.twiliocdn.com https://sdk.twilio.com
```

License
-------

See [LICENSE.md](https://github.com/twilio/twilio-voice.js/blob/master/LICENSE.md)

---
_Source: https://npm.io/package/@twilio/voice-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
