> ## 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.

# Setup

> CometChat Calling SDK v5 - Setup for JavaScript

<Info>
  **Faster Integration with UI Kits**

  If you're using CometChat UI Kits, voice and video calling can be quickly integrated:

  * Incoming & outgoing call screens
  * Call buttons with one-tap calling
  * Call logs with history

  👉 [React UI Kit Calling Integration](/ui-kit/react/calling-integration)

  Use this Calls SDK directly only if you need custom call UI or advanced control.
</Info>

This guide walks you through installing the CometChat Calls SDK and initializing it in your web application.

## Install the SDK

Install the CometChat Calls SDK using npm or yarn:

<Tabs>
  <Tab title="npm">
    ```bash theme={null}
    npm install @cometchat/calls-sdk-javascript@5.0.0
    ```
  </Tab>

  <Tab title="yarn">
    ```bash theme={null}
    yarn add @cometchat/calls-sdk-javascript@5.0.0
    ```
  </Tab>
</Tabs>

## Import the SDK

Import the `CometChatCalls` class in your JavaScript or TypeScript file:

```javascript theme={null}
import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
```

## Initialize CometChat Calls

The `init()` method initializes the SDK with your app credentials. Call this method once when your application starts.

### CallAppSettings

The initialization requires a configuration object with the following properties:

| Parameter | Type   | Required | Description                           |
| --------- | ------ | -------- | ------------------------------------- |
| `appId`   | String | Yes      | Your CometChat App ID                 |
| `region`  | String | Yes      | Your app region (`us`, `eu`, or `in`) |

```javascript theme={null}
const appId = "APP_ID"; // Replace with your App ID
const region = "REGION"; // Replace with your Region ("us", "eu", or "in")

const callAppSettings = {
  appId: appId,
  region: region,
};

const result = await CometChatCalls.init(callAppSettings);

if (result.success) {
  console.log("CometChat Calls SDK initialized successfully");
} else {
  console.error("CometChat Calls SDK initialization failed:", result.error);
}
```

The `init()` method returns an object with:

| Property  | Type           | Description                            |
| --------- | -------------- | -------------------------------------- |
| `success` | Boolean        | `true` if initialization succeeded     |
| `error`   | Object \| null | Error details if initialization failed |

## Browser Requirements

The Calls SDK requires a modern browser with WebRTC support:

| Browser | Minimum Version |
| ------- | --------------- |
| Chrome  | 72+             |
| Firefox | 68+             |
| Safari  | 12.1+           |
| Edge    | 79+             |

<Note>
  HTTPS is required for camera and microphone access in production. Localhost is exempt from this requirement during development.
</Note>

## Permissions

The browser will prompt users for camera and microphone permissions when joining a call. Ensure your application handles permission denials gracefully.

```javascript theme={null}
// Check if permissions are granted
async function checkMediaPermissions() {
  try {
    const stream = await navigator.mediaDevices.getUserMedia({ 
      video: true, 
      audio: true 
    });
    stream.getTracks().forEach(track => track.stop());
    return true;
  } catch (error) {
    console.error("Media permissions denied:", error);
    return false;
  }
}
```
