# twilio-sync

> Twilio Sync client library

Latest version **4.0.1** (published 2026-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install twilio-sync
pnpm add twilio-sync
yarn add twilio-sync
bun add twilio-sync
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2026-09-01 |
| First published | 2016-07-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20 |
| Dependencies | 9 |
| Unpacked size | 5.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Twilio |
| Maintainers | twilio-supply-chain |

## Links

- npm: https://www.npmjs.com/package/twilio-sync
- npm.io page: https://npm.io/package/twilio-sync

## Dependencies (9)

- [core-js](https://npm.io/package/core-js.md) ^3.17.3
- [loglevel](https://npm.io/package/loglevel.md) ^1.8.0
- [platform](https://npm.io/package/platform.md) ^1.3.6
- [twilsock](https://npm.io/package/twilsock.md) ^1.0.2
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.17.0
- [iso8601-duration](https://npm.io/package/iso8601-duration.md) =1.2.0
- [@twilio/operation-retrier](https://npm.io/package/@twilio/operation-retrier.md) ^5.0.0
- [@twilio/replay-event-emitter](https://npm.io/package/@twilio/replay-event-emitter.md) ^1.0.0
- [@twilio/declarative-type-validator](https://npm.io/package/@twilio/declarative-type-validator.md) ^1.0.0

## Recent versions

- 4.0.1 (latest) — 2026-09-01
- 4.0.1-rc.0 (rc) — 2026-08-31
- 4.0.0-rc.13 (alpha) — 2026-03-17
- 3.3.11-canary.13 (canary) — 2026-02-19
- 0.5.3-dsync-796-v0.5.894 (dev) — 2017-12-15
- 4.0.0 — 2026-03-18
- 4.0.0-rc.12 — 2026-03-17
- 4.0.0-rc.11 — 2026-02-27
- 3.4.0 — 2026-02-19
- 3.4.0-rc.2 — 2026-02-19
- 3.3.11-rc.1 — 2026-02-19
- 3.3.10 — 2025-11-18
- 3.3.10-rc.0 — 2025-11-18
- 3.3.9 — 2025-09-29
- 3.3.9-rc.4 — 2025-09-29
- … 626 more at https://npm.io/package/twilio-sync/versions

## README

# Twilio Sync JavaScript client library

Twilio Sync is Twilio's state synchronization service, offering two-way real-time communication between browsers, mobiles, and the cloud.
Visit our official site for more details: [https://www.twilio.com/sync](https://www.twilio.com/sync)

## Installation

### via NPM

```
npm install --save twilio-sync
```

Using this method, you can `require` twilio-sync.js like so:

```
const { SyncClient } = require('twilio-sync');
const syncClient = new SyncClient(token);
```

### via CDN

Releases of twilio-sync.js are hosted on a CDN, and you can include these
directly in your web app using a &lt;script&gt; tag.

```
<script type="text/javascript" src="https://sdk.twilio.com/js/sync/v4.0/twilio-sync.min.js"></script>
```

Using this method, twilio-sync.js will set a browser global:

```
const syncClient = new Twilio.Sync.Client(token);
```

## Usage

To use the library, you need to generate an [Access Token](https://www.twilio.com/docs/sync/identity-and-access-tokens) and pass it to the Sync Client constructor.
The Twilio SDK Starter applications for [Node.js](https://github.com/TwilioDevEd/sdk-starter-node), [Java](https://github.com/TwilioDevEd/sdk-starter-java), [PHP](https://github.com/TwilioDevEd/sdk-starter-php), [Ruby](https://github.com/TwilioDevEd/sdk-starter-ruby), [Python](https://github.com/TwilioDevEd/sdk-starter-python), [C#](https://github.com/TwilioDevEd/sdk-starter-csharp) provide an easy way to set up a token generator locally.
Alternatively, you can set up a [Twilio Function based on the _Sync Access Token_ template](https://www.twilio.com/console/runtime/functions/manage).

```
// Obtain a JWT access token: https://www.twilio.com/docs/sync/identity-and-access-tokens
const token = '<your-access-token-here>';
const syncClient = new Twilio.Sync.Client(token);

// Open a Document by unique name and update its data
syncClient.document('MyDocument')
  .then(function(document) {
    // Listen to updates on the Document
    document.on('updated', function(event) {
      console.log('Received Document update event. New data:', event.data);
    });

    // Update the Document data
    const newData = { temperature: 23 };
    return document.set(newData);
  })
  .then(function(updateResult) {
    console.log('The Document was successfully updated', updateResult)
  })
  .catch(function(error) {
    console.error('Unexpected error', error)
  });
```

For more code examples for Documents and other Sync objects, refer to the [SDK API Docs](https://sdk.twilio.com/js/sync/latest/docs).

## Changelog

See this [link](https://www.twilio.com/docs/sync/javascript/changelog).

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