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

# Standalone Calling

> CometChat Calling SDK v4 - Stable Release - Standalone Calling for React Native

<Info>
  **Quick Reference** - Generate token and start a standalone call session:

  ```javascript theme={null}
  // Generate call token (auth token from REST API, not Chat SDK)
  const callToken = await CometChatCalls.generateToken(sessionId, userAuthToken);

  // Configure and render
  const callSettings = new CometChatCalls.CallSettingsBuilder()
    .enableDefaultLayout(true)
    .setIsAudioOnlyCall(false)
    .build();

  // <CometChatCalls.Component callSettings={callSettings} callToken={callToken} />
  ```
</Info>

<Note>
  **Available via:** SDK | UI Kits
</Note>

## Overview

This section demonstrates how to implement calling functionality using only the CometChat Calls SDK, without requiring the Chat SDK. This is ideal for applications that need video/audio calling capabilities without the full chat infrastructure.

<Note>
  Before you begin, ensure you have completed the [Calls SDK setup](/calls/v4/react-native/setup).
</Note>

## User Authentication

To start a call session, you need a user auth token. Since this implementation doesn't use the Chat SDK, you'll need to obtain the auth token via the CometChat REST API.

<Note>
  To understand user authentication in CometChat, see the [User Auth](/fundamentals/user-auth) documentation.
</Note>

You can obtain the auth token using one of these REST API endpoints:

* [Create Auth Token](/rest-api/auth-tokens/create) — Creates a new auth token for a user
* [Get Auth Token](/rest-api/auth-tokens/get) — Retrieves an existing auth token

<Warning>
  Auth tokens grant access to call sessions on behalf of a user. Never expose auth tokens in client-side code in production. Use a secure backend to generate and deliver tokens to your app.
</Warning>

## Generate Call Token

Use the `generateToken()` method to create a call token:

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    const sessionId = "UNIQUE_SESSION_ID";
    const userAuthToken = "USER_AUTH_TOKEN";

    CometChatCalls.generateToken(sessionId, userAuthToken).then(
      (callToken) => {
        console.log("Call token generated:", callToken.token);
      },
      (error) => {
        console.log("Token generation failed:", error);
      }
    );
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    const sessionId: string = "UNIQUE_SESSION_ID";
    const userAuthToken: string = "USER_AUTH_TOKEN";

    CometChatCalls.generateToken(sessionId, userAuthToken).then(
      (callToken: GenerateToken) => {
        console.log("Call token generated:", callToken.token);
      },
      (error: CometChat.CometChatException) => {
        console.log("Token generation failed:", error);
      }
    );
    ```
  </Tab>
</Tabs>

| Parameter       | Description                                                                             |
| --------------- | --------------------------------------------------------------------------------------- |
| `sessionId`     | A unique session ID for the call. Share this ID for participants to join the same call. |
| `userAuthToken` | The user auth token obtained from the CometChat REST API.                               |

## Start Call Session

Use the `CometChatCalls.Component` to render the call UI.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    const callListener = new CometChatCalls.OngoingCallListener({
      onUserJoined: (user) => console.log("User joined:", user),
      onUserLeft: (user) => console.log("User left:", user),
      onUserListUpdated: (userList) => console.log("User list updated:", userList),
      onCallEnded: () => {
        CometChatCalls.endSession();
      },
      onCallEndButtonPressed: () => {
        CometChatCalls.endSession();
      },
      onError: (error) => console.log("Call error:", error),
      onAudioModesUpdated: (audioModes) => console.log("Audio modes updated:", audioModes),
      onSessionTimeout: () => console.log("Session timed out")
    });

    const callSettings = new CometChatCalls.CallSettingsBuilder()
      .enableDefaultLayout(true)
      .setIsAudioOnlyCall(false)
      .setCallEventListener(callListener)
      .build();

    return (
      <View style={{ height: '100%', width: '100%', position: 'relative' }}>
        <CometChatCalls.Component callSettings={callSettings} callToken={callToken} />
      </View>
    );
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    const callListener = new CometChatCalls.OngoingCallListener({
      onUserJoined: (user: CometChat.User) => console.log("User joined:", user),
      onUserLeft: (user: CometChat.User) => console.log("User left:", user),
      onUserListUpdated: (userList: CometChat.User[]) => console.log("User list updated:", userList),
      onCallEnded: () => {
        CometChatCalls.endSession();
      },
      onCallEndButtonPressed: () => {
        CometChatCalls.endSession();
      },
      onError: (error: CometChat.CometChatException) => console.log("Call error:", error),
      onAudioModesUpdated: (audioModes: string[]) => console.log("Audio modes updated:", audioModes),
      onSessionTimeout: () => console.log("Session timed out")
    });

    const callSettings = new CometChatCalls.CallSettingsBuilder()
      .enableDefaultLayout(true)
      .setIsAudioOnlyCall(false)
      .setCallEventListener(callListener)
      .build();

    return (
      <View style={{ height: '100%', width: '100%', position: 'relative' }}>
        <CometChatCalls.Component callSettings={callSettings} callToken={callToken} />
      </View>
    );
    ```
  </Tab>
</Tabs>

## End Call Session

To end the call session, call `CometChatCalls.endSession()` in the `onCallEndButtonPressed()` callback.

```javascript theme={null}
CometChatCalls.endSession();
```

## Methods

### Switch Camera

```javascript theme={null}
CometChatCalls.switchCamera();
```

### Mute Audio

```javascript theme={null}
CometChatCalls.muteAudio(true); // true to mute, false to unmute
```

### Pause Video

```javascript theme={null}
CometChatCalls.pauseVideo(true); // true to pause, false to resume
```

### Set Audio Mode

```javascript theme={null}
CometChatCalls.setAudioMode(CometChat.AUDIO_MODE.EARPIECE);
```

### Switch To Video Call

```javascript theme={null}
CometChatCalls.switchToVideoCall();
```

<AccordionGroup>
  <Accordion title="Best Practices">
    * Generate call tokens just before use — they are session-specific and time-limited
    * Use a shared session ID for participants to join the same call
    * Secure your auth tokens — generate them server-side and deliver securely to the client
    * Clean up listeners on component unmount
    * Wrap the call component in a full-screen container
  </Accordion>

  <Accordion title="Troubleshooting">
    * **Call token generation fails:** Verify the auth token is valid and hasn't expired
    * **Call UI does not render:** Ensure the component is wrapped in a `View` with explicit dimensions
    * **Participants can't join the same call:** Both participants must use the exact same `sessionId`
    * **Audio or video not working:** Check device permissions for camera and microphone
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Calls SDK Setup" icon="gear" href="/calls/v4/react-native/setup">
    Install dependencies, configure permissions, and initialize the Calls SDK
  </Card>

  <Card title="Recording" icon="circle-dot" href="/calls/v4/react-native/recording">
    Record call sessions for playback and compliance
  </Card>

  <Card title="Video View Customisation" icon="sliders" href="/calls/v4/react-native/video-view-customisation">
    Customize the main video container and participant tiles
  </Card>

  <Card title="Call Session" icon="video" href="/calls/v4/react-native/call-session">
    Full call session management with the Chat SDK integration
  </Card>
</CardGroup>
