Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal
Developer Documentation is moving soon to a new location → https://developer.vonage.com Content will remain unchanged.

OpenTok.js

The OpenTok.js library lets you use Vonage Video API-powered video sessions on the web.

This page covers the following topics:


Important notes:

Chrome M136 on Windows – audio device detection issue We are aware of a Chrome M136 issue on Windows where the browser may intermittently respond slowly or fail when retrieving audio device information. This is a known issue and has been addressed in Chrome version 137.0.7150.0, with the fix also merged into an upcoming patch of Chrome 136 expected to be released shortly. In the meantime, if you encounter this issue, we recommend either rolling back to Chrome 135 and pinning it, or using an alternate browser. Please contact support if you need help implementing a workaround.

Issues fixed in Safari 15.4 and 15.5. Safari versions 15.4 and 15.5 (which ship with iOS 15.4 and 15.5 and macOS 12.3 and 12.4) fix the following issues, which could affect apps that use OpenTok.js (in Safari):

  • Audio issues when using certain models of Bluetooth headsets. On certain models of Bluetooth headsets, audio could drop out. This WebKit bug is fixed in Safari 15.4.
  • Echo issues when switching microphones in macOS Safari. Switching the microphone used by a publisher could result in an echo of the publisher's audio. The echo did not appear on the subscriber's side. This WebKit bug is fixed in Safari 15.5.
  • Critical bug publishing H.264 video in routed sessions in iOS 15.1. In iOS 15.1, publishing H.264 video in routed sessions would fail. This WebKit bug was fixed in Safari 15.4.
  • Low audio volume is iOS Safari. This WebKit bug is fixed in Safari 15.4.

End-to-end encryption — In OpenTok.js 2.27.0, end-to-end encryption will not work with clients using an earlier version of OpenTok.js. When you upgrade your app to use OpenTok.js 2.27.0+, make sure all clients are using OpenTok.js 2.27.0+ if the app uses end-to-end encryption..

Overview

All applications that use the Vonage Video API are composed of two parts:

The client SDK for building web-based applications that use the Vonage Video API is OpenTok.js. This JavaScript library provides most of the core functionality for your app, including:

Client SDKs are also available for iOS and Android. All OpenTok client SDKs can interact with one another. You can learn more about the basics of OpenTok clients, servers, sessions and more on our Video API Basics page.

The current version of the OpenTok.js library can interoperate with OpenTok apps written with version 2.32+ of the OpenTok client SDKs:

Building with OpenTok.js

The best way to learn how to use the OpenTok.js library is to follow our Basic Video Chat tutorial for web:

View tutorial

Once you understand the basics of building with OpenTok.js, you can get more detailed information and learn how to customize your application with our Developer Guides. To investigate specific API classes and methods, you can review the OpenTok.js Reference.

Loading OpenTok.js

To load OpenTok.js in your web page, add the following script tag:

<script src="https://static.opentok.com/v2/js/opentok.min.js"></script>  

Installation via GitHub Packages

In addition to installing from the npm registry, the Client SDK packages are also available through GitHub Packages' NPM registry. This provides an alternative distribution channel for enterprise environments that require GitHub-based package management.

Available Packages

The following package is published to GitHub Packages:

Setup Instructions

To install packages from GitHub Packages' NPM registry, you need to configure npm to authenticate with GitHub:

1. Create a GitHub Personal Access Token (PAT)

Generate a personal access token with read:packages scope from your GitHub account settings.

2. Configure your .npmrc file

Add the following configuration to your project's .npmrc file or your user-level ~/.npmrc file:

//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
@vonage:registry=https://npm.pkg.github.com

Replace YOUR_GITHUB_TOKEN with your GitHub personal access token.

3. Install the package

Once configured, you can install the package using the standard npm install command:

npm install @opentok/client

Note on Package Availability

Both the traditional npm registry and GitHub Packages registry are kept in sync. You can choose either distribution method based on your organization's package management preferences. The traditional npm installation method (via npm install @opentok/client from the default registry) remains fully supported and requires no additional configuration.

For more information about working with GitHub Packages' NPM registry, see the GitHub Packages documentation.

Browser support

The OpenTok.js library is currently supported in:

Important: OpenTok.js version 2.16 was the last version to support the OpenTok Plugin for Internet Explorer. OpenTok.js version 2.16 was deprecated in May 2020 for the Standard environment and June 2020 for the Enterprise environment.

System requirements

For reliable video streaming in modern browsers, ensure your device meets these recommended specs: