Skip to main content
Quick Reference for AI Agents & Developers
// Install: npm install @cometchat/calls-sdk-javascript

import { CometChatCalls } from "@cometchat/calls-sdk-javascript";

// Initialize Calls SDK (after Chat SDK init)
const callAppSettings = new CometChatCalls.CallAppSettingsBuilder()
  .setAppId(APP_ID)
  .setRegion(REGION)
  .build();
await CometChatCalls.init(callAppSettings);

// For dedicated deployments, add: .setHost("https://your-custom-url.cometchat.io")
Set up the CometChat Calls SDK to add voice and video calling capabilities to your web application.

Prerequisites

Before you begin:
  1. Create a CometChat account and app
  2. Note your App ID, Auth Key, and Region from the Dashboard credentials section
  3. Complete the Chat SDK Setup (unless using Standalone Calling)

Installation

npm install @cometchat/calls-sdk-javascript

Import

Import the CometChatCalls class in your application:
import { CometChatCalls } from "@cometchat/calls-sdk-javascript";

Initialize

Initialize the Calls SDK before using any calling features. Call init() on app startup, typically in your main entry file.
const appId = "YOUR_APP_ID";
const region = "YOUR_REGION"; // e.g., "us", "eu"

const callAppSettings = new CometChatCalls.CallAppSettingsBuilder()
  .setAppId(appId)
  .setRegion(region)
  .build();

CometChatCalls.init(callAppSettings).then(
  () => {
    console.log("CometChatCalls initialized successfully");
  },
  (error) => {
    console.log("CometChatCalls initialization failed:", error);
  }
);
Replace YOUR_APP_ID and YOUR_REGION with your actual CometChat credentials from the Dashboard.

Configuration Options

The CallAppSettingsBuilder provides these configuration methods:
MethodDescriptionRequired
setAppId(appId)Your CometChat App IDYes
setRegion(region)Region where your app was created (us, eu, etc.)Yes
setHost(host)Custom client URL for dedicated deploymentsNo

Dedicated Deployment

For dedicated CometChat deployments, use setHost() to specify your custom URL:
const callAppSettings = new CometChatCalls.CallAppSettingsBuilder()
  .setAppId(appId)
  .setRegion(region)
  .setHost("https://your-custom-url.cometchat.io")
  .build();

Complete Setup Example

Here’s a complete initialization flow with both Chat and Calls SDKs:
import { CometChat } from "@cometchat/chat-sdk-javascript";
import { CometChatCalls } from "@cometchat/calls-sdk-javascript";

const appId = "YOUR_APP_ID";
const region = "YOUR_REGION";

async function initializeCometChat() {
  try {
    // Initialize Chat SDK
    const appSettings = new CometChat.AppSettingsBuilder()
      .subscribePresenceForAllUsers()
      .setRegion(region)
      .autoEstablishSocketConnection(true)
      .build();

    await CometChat.init(appId, appSettings);
    console.log("Chat SDK initialized");

    // Initialize Calls SDK
    const callAppSettings = new CometChatCalls.CallAppSettingsBuilder()
      .setAppId(appId)
      .setRegion(region)
      .build();

    await CometChatCalls.init(callAppSettings);
    console.log("Calls SDK initialized");

    return true;
  } catch (error) {
    console.error("Initialization failed:", error);
    return false;
  }
}

// Call on app startup
initializeCometChat();

Next Steps