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

# Screen Sharing

> CometChat Calling SDK v5 - Screen Sharing for JavaScript

Share your screen with other participants during a call. The browser will prompt users to select which screen, window, or browser tab to share.

## Start Screen Sharing

Begin sharing your screen:

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

The browser will display a dialog allowing the user to choose:

* Entire screen
* Application window
* Browser tab

## Stop Screen Sharing

Stop the current screen share:

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

## Screen Sharing Events

### Local Screen Share Events

Monitor your own screen sharing state:

```javascript theme={null}
CometChatCalls.addEventListener("onScreenShareStarted", () => {
  console.log("You started screen sharing");
});

CometChatCalls.addEventListener("onScreenShareStopped", () => {
  console.log("You stopped screen sharing");
});
```

### Participant Screen Share Events

Monitor when other participants start or stop screen sharing:

```javascript theme={null}
CometChatCalls.addEventListener("onParticipantStartedScreenShare", (participant) => {
  console.log(`${participant.name} started screen sharing`);
});

CometChatCalls.addEventListener("onParticipantStoppedScreenShare", (participant) => {
  console.log(`${participant.name} stopped screen sharing`);
});
```

## Screen Sharing Button

### Hide Screen Sharing Button

To hide the screen sharing button from the control panel:

```javascript theme={null}
const callSettings = {
  hideScreenSharingButton: true,
  // ... other settings
};
```

### Listen for Button Clicks

Intercept screen share button clicks for custom behavior:

```javascript theme={null}
CometChatCalls.addEventListener("onScreenShareButtonClicked", () => {
  console.log("Screen share button clicked");
});
```

## Browser Support

Screen sharing requires browser support for the `getDisplayMedia` API:

| Browser | Support        |
| ------- | -------------- |
| Chrome  | ✅ Full support |
| Firefox | ✅ Full support |
| Safari  | ✅ Safari 13+   |
| Edge    | ✅ Full support |

<Note>
  Screen sharing requires HTTPS in production. Localhost is exempt during development.
</Note>
