# @dytesdk/twilio-shim

> Twilio Shim

Latest version **0.0.3** (published 2023-12-05) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @dytesdk/twilio-shim
pnpm add @dytesdk/twilio-shim
yarn add @dytesdk/twilio-shim
bun add @dytesdk/twilio-shim
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-12-05 |
| First published | 2023-04-30 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 35.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | dyteindia |

## Links

- npm: https://www.npmjs.com/package/@dytesdk/twilio-shim
- Homepage: https://dyte.io
- Issues: https://community.dyte.io
- npm.io page: https://npm.io/package/@dytesdk/twilio-shim

## Dependencies (2)

- [events](https://npm.io/package/events.md) ^3.3.0
- [@dytesdk/web-core](https://npm.io/package/@dytesdk/web-core.md) ^1.20.0

## Recent versions

- 0.0.3 (latest) — 2023-12-05
- 0.0.2 — 2023-04-30
- 0.0.1 — 2023-04-30

## README

<!-- PROJECT LOGO -->
<p align="center">
  <a href="https://dyte.io">
    <img src="https://assets.dyte.io/logo-outlined.png" alt="Logo" width="120" />
  </a>

  <h2 align="center">Twilio shim by dyte</h3>

  <p align="center">
    <br />
    <a href="https://docs.dyte.io"><strong>Explore the docs »</strong></a>
    <br />
    <br />
    <a href="https://app.dyte.io">View Demo</a>
    ·
    <a href="https://community.dyte.io">Report Bug</a>
    ·
    <a href="https://community.dyte.io">Request Feature</a>
  </p>
</p>

<!-- TABLE OF CONTENTS -->

## Table of Contents

- [About the Project](#about-the-project)
  - [Built With](#built-with)
- [Getting Started](#getting-started)
- [Usage](#usage)
- [Version History](#version-history)
- [Roadmap](#roadmap)
- [About](#about)

<!-- ABOUT THE PROJECT -->

## About The Project

This package `@dytesdk/twilio-shim` is a wrapper over the [Dyte SDK](https://dyte.io) with a Twilio Video compatible external API. It is a drop-in replacement for Twilio Video.js, and supports most of the methods and events that are
present in the Twilio Video SDK.

### Built With
- [@dytesdk/web-core](https://www.npmjs.com/package/@dytesdk/web-core)
- [Typescript](https://typescriptlang.org)

<!-- GETTING STARTED -->

## Getting Started

You can install the `@dytesdk/twilio-shim` from the [NPM Registry](https://npmjs.com/) using the `npm install` command.

```bash
npm install @dytesdk/twilio-shim
```

## Usage

The `@dytesdk/twilio-shim` shares the same API as the Twilio Video SDK. You can use most of the methods that are supported by it. Here's a [compatibility specification](https://dyte.notion.site/Twilio-Shim-Compatibility-Spec-38090f970c4845529cb709f2222b438b)
that describes the methods from `twilio-video` that are supported by this `@dytesdk/twilio-shim` package.

Here are a few examples:

```js
const { connect } = require('@dytesdk/twilio-shim');

const authToken = '<AUTH_TOKEN_FROM_DYTE_API>';
const room = await connect(authToken, {audio: false, video: true});
console.log(`Successfully joined a Room: ${room.name}`);
console.log(room);
room.on('participantConnected', participant => {
    console.log(`A remote Participant connected: ${participant}`);
});
```

```js
const { connect } = require('@dytesdk/twilio-shim');

const authToken = '<AUTH_TOKEN_FROM_DYTE_API>';
const room = await connect(authToken, {audio: false, video: false});
room.on('participantConnected', participant => {
    console.log(`Participant "${participant.identity}" connected`);

    participant.tracks.forEach(publication => {
        if (publication.isSubscribed) {
            const track = publication.track;
            document.getElementById('remote-media-div').appendChild(track.attach());
        }
    });

    participant.on('trackSubscribed', track => {
        console.log('Subscribed to track', track);
        const element = track.attach();
        console.log(element);
        document.getElementById('remote-media-div').appendChild(element);
    });
});
```

```js
const { connect } = require('@dytesdk/twilio-shim');

const authToken = '<AUTH_TOKEN_FROM_DYTE_API>';
const room = await connect(authToken, {audio: true, video: true});

room.localParticipant.audioTracks.forEach(publication => {
    publication.track.disable();
});

room.localParticipant.videoTracks.forEach(publication => {
    publication.track.disable();
});


// Enable audio and video tracks after 5 seconds
setTimeout(() => {
    room.localParticipant.audioTracks.forEach(publication => {
        publication.track.enable();
    });

    room.localParticipant.videoTracks.forEach(publication => {
        publication.track.enable();
    });
}, 5000);
```

<!-- CHANGELOG -->

## About

`twilio-shim` is created & maintained by Dyte, Inc. You can find us on Twitter - [@dyte_io](https://twitter.com/dyte_io) or write to us at `dev [at] dyte.io`.

The names and logos for Dyte are trademarks of Dyte, Inc.

We love open source software! See [our other projects](https://github.com/dyte-in) and [our products](https://dyte.io).

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