> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Calls SDK

> Use CometChat Calls SDK v5 for JavaScript to add voice and video calling, call sessions, participants, layouts, and in-call features.

The CometChat Calls SDK enables real-time voice and video calling capabilities in your web application. Built on top of WebRTC, it provides a complete calling solution with built-in UI components and extensive customization options.

## Prerequisites

Before integrating the Calls SDK, ensure you have:

1. **CometChat Account**: [Sign up](https://app.cometchat.com/signup) and create an app to get your App ID, Region, and API Key
2. **CometChat Users**: Users must exist in CometChat to use calling features. For testing, create users via the [Dashboard](https://app.cometchat.com) or [REST API](https://www.cometchat.com/docs/rest-api/users/create.md). Authentication is handled by the Calls SDK - see [Authentication](https://www.cometchat.com/docs/calls/javascript/authentication.md)
3. **Browser Requirements**: See [Browser Compatibility](#browser-compatibility) below
4. **Permissions**: Camera and microphone permissions for video/audio calls

## Browser Compatibility

The Calls SDK requires a modern browser with WebRTC support:

| Browser | Minimum Version | Notes |
| - | - | - |
| Chrome | 72+ | Full support |
| Firefox | 68+ | Full support |
| Safari | 12.1+ | Full support |
| Edge | 79+ | Chromium-based |
| Opera | 60+ | Full support |
| Samsung Internet | 12+ | Full support |

### Requirements

* **HTTPS**: Required for camera/microphone access in production. Localhost is exempt during development.
* **WebRTC**: The browser must support WebRTC APIs (`getUserMedia`, `RTCPeerConnection`)
* **JavaScript**: ES6+ support required

### Mobile Browsers

| Browser | Support |
| - | - |
| Chrome for Android | ✅ Full support |
| Safari for iOS | ✅ iOS 12.1+ |
| Firefox for Android | ✅ Full support |
| Samsung Internet | ✅ Full support |

> [!NOTE]
>
> For native mobile apps, consider using the [iOS](https://www.cometchat.com/docs/calls/ios/overview.md) or [Android](https://www.cometchat.com/docs/calls/android/overview.md) SDKs for better performance and native features like CallKit/VoIP.

## Framework Integrations

Get started quickly with framework-specific guides that include complete setup, authentication, and working call implementations:

> [card] [React](https://www.cometchat.com/docs/calls/javascript/react-integration.md)
>
> Context provider pattern with hooks

> [card] [Vue](https://www.cometchat.com/docs/calls/javascript/vue-integration.md)
>
> Composables and reactive state management

> [card] [Angular](https://www.cometchat.com/docs/calls/javascript/angular-integration.md)
>
> Service-based architecture with RxJS

> [card] [Next.js](https://www.cometchat.com/docs/calls/javascript/nextjs-integration.md)
>
> SSR handling with App Router and Pages Router

> [card] [Ionic](https://www.cometchat.com/docs/calls/javascript/ionic-integration.md)
>
> Cross-platform with Angular, React, and Vue

## Call Flow

```mermaid theme={null}
sequenceDiagram
    participant App
    participant CometChatCalls
    
    App->>CometChatCalls: init()
    App->>CometChatCalls: login()
    App->>CometChatCalls: generateToken()
    App->>CometChatCalls: joinSession()
    CometChatCalls-->>App: Session joined
    App->>CometChatCalls: Actions (mute, pause, etc.)
    CometChatCalls-->>App: Event callbacks
    App->>CometChatCalls: leaveSession()
```

Every call is a session joined by ID. Where the ID comes from depends on the kind of call:

* **Direct call**: your app shares a session ID (for example in a message) and each participant generates a token and calls `joinSession` with it. Group calls and meetings work this way.
* **Ringing call**: the caller starts it with `CometChatCalls.initiateCall`, the callee's open tabs receive it through the Chat SDK and prepare it with `CometChatCalls.connect`, and both sides join the prepared session with `session.join(container)` once the callee answers. See [Ringing](https://www.cometchat.com/docs/calls/javascript/ringing.md).

## Features

> [card] [Ringing](https://www.cometchat.com/docs/calls/javascript/ringing.md)
>
> Start a call, ring the callee's open tabs and phones, show "Ringing…", answer, decline, cancel and end

> [card] [Call Layouts](https://www.cometchat.com/docs/calls/javascript/call-layouts.md)
>
> Tile, Sidebar, and Spotlight view modes for different call scenarios

> [card] [Recording](https://www.cometchat.com/docs/calls/javascript/recording.md)
>
> Record call sessions for later playback

> [card] [Call Logs](https://www.cometchat.com/docs/calls/javascript/call-logs.md)
>
> Retrieve call history and details

> [card] [Participant Management](https://www.cometchat.com/docs/calls/javascript/participant-management.md)
>
> Mute, pin, and manage call participants

> [card] [Screen Sharing](https://www.cometchat.com/docs/calls/javascript/screen-sharing.md)
>
> Share your screen with other participants

> [card] [Virtual Background](https://www.cometchat.com/docs/calls/javascript/virtual-background.md)
>
> Apply blur or custom image backgrounds

> [card] [Raise Hand](https://www.cometchat.com/docs/calls/javascript/raise-hand.md)
>
> Signal to get attention during calls

> [card] [Idle Timeout](https://www.cometchat.com/docs/calls/javascript/idle-timeout.md)
>
> Automatic session termination when alone in a call

## Architecture

The SDK is organized around these core components:

| Component | Description |
| - | - |
| `CometChatCalls` | Main entry point for SDK initialization, authentication, session management, and call actions |
| `CallAppSettings` | Configuration object for SDK initialization (App ID, Region) |
| `CallSettings` | Configuration object for individual call sessions |
| `CallSession` | The session object `initiateCall`, `connect` and `getActiveSession()` return: `sessionId`, `prepareStatus`, `join(container)`, `leave()` and every session action |
| `addEventListener` | Method to register event listeners for session, participant, media, and UI events |

## Single Active Session

`CometChatCalls` is a singleton, and it tracks one active call session at a time. Every session method acts on that current session, which is why methods like `leaveSession()` take no session ID:

```javascript theme={null}
// Joins and becomes the active session
await CometChatCalls.joinSession(callToken, callSettings, container);

// Acts on whatever session is currently active - no session ID needed
CometChatCalls.leaveSession();
```

| Behavior | Detail |
| - | - |
| One session at a time | The SDK does not support being connected to two sessions simultaneously. Leave the current session before joining another. A session that is only prepared (an outgoing call still ringing) counts too: `joinSession` refuses to run while it exists. |
| Session methods take no session ID | `leaveSession()` and the other [actions](https://www.cometchat.com/docs/calls/javascript/actions.md) apply to the active session only. |
| Actions apply to the active session | `muteAudio()`, `pauseVideo()`, `startScreenShare()`, and similar methods target the session currently in progress. |
| Events are not session-scoped | Listeners registered with `addEventListener` fire for the active session. |

To move a user from one call to another, leave the current session, wait for the `onSessionLeft` event, then generate a token for the new session and join:

```javascript theme={null}
CometChatCalls.addEventListener("onSessionLeft", async () => {
  const { token } = await CometChatCalls.generateToken(nextSessionId);
  await CometChatCalls.joinSession(token, callSettings, container);
});

CometChatCalls.leaveSession();
```

> [!NOTE]
>
> The limit applies per SDK instance. Separate browser tabs or windows each load their own instance, so they can hold separate sessions independently.

## Sample App

> [card] [React](https://github.com/cometchat/calls-sdk-javascript/tree/v5/sample-apps/cometchat-calls-sample-app-react)
>
> React sample app

> [card] [Angular](https://github.com/cometchat/calls-sdk-javascript/tree/v5/sample-apps/cometchat-calls-sample-app-angular)
>
> Angular sample app

> [card] [Vue](https://github.com/cometchat/calls-sdk-javascript/tree/v5/sample-apps/cometchat-calls-sample-app-vue)
>
> Vue sample app

> [card] [Svelte](https://github.com/cometchat/calls-sdk-javascript/tree/v5/sample-apps/cometchat-calls-sample-app-svelte)
>
> Svelte sample app

> [card] [Ionic](https://github.com/cometchat/calls-sdk-javascript/tree/v5/sample-apps/cometchat-calls-sample-app-ionic)
>
> Ionic sample app

> [card] [Changelog](https://github.com/cometchat/calls-sdk-javascript/releases)
>
> View the latest releases and changes


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.