Skip to main content
The Ant Media Server JavaScript SDK enables WebRTC streaming in web browsers. It provides a simple API for publishing and playing streams with ultra-low latency.

Installation

CDN

Include the SDK directly in your HTML:

NPM

Install via npm for modern web applications:
Then import in your JavaScript:

Basic Usage

Initialize the SDK

Create a WebRTC adaptor instance:

Publishing a Stream

Publish video/audio from the user’s camera and microphone:

Playing a Stream

Play an existing stream:

Conference Room

Join a multi-party conference room:

Screen Sharing

Share your screen instead of camera:

Data Channels

Send real-time data alongside video:

Configuration Options

Media Constraints

Customize video and audio capture:

ICE Servers

Configure STUN/TURN servers for NAT traversal:

Event Callbacks

Handle SDK events:

Stop Publishing/Playing

Stop streams when done:

Sample Application

View the complete sample application:

Resources

JavaScript SDK Repository

View source code, examples, and contribute on GitHub

Browser Compatibility

The JavaScript SDK supports all modern browsers with WebRTC:
  • Chrome 74+
  • Firefox 66+
  • Safari 12.1+
  • Edge 79+
  • Opera 62+
WebRTC requires HTTPS in production. Localhost works with HTTP for development only.

Next Steps

REST API

Control streams with the REST API

Authentication

Secure your streams with tokens