SSE Hooks

useScreenShare

Custom hook that captures the user's screen or specific application window.

Installation

npx sse-tool add use-screen-share

Usage

import { useScreenShare } from "./{hooks file}";

const { stream, error, startCapture, stopCapture } = useScreenShare();

return (
  <div>
    {error && <p>Error: {error}</p>}
    <video
      autoPlay
      muted
      playsInline
      ref={(node) => {
        if (node && stream) node.srcObject = stream;
      }}
    />
    <button onClick={() => startCapture()}>Share Screen</button>
    <button onClick={stopCapture}>Stop Sharing</button>
  </div>
);

API

Parameters

NameTypeDescription
initialOptionsUseScreenShareOptionsThe initial options for screen sharing (video/audio).

Return Value

Returns Object.

An object containing the stream, error state, and control functions.

Changelog

c165d — feat: enhance useRoleGuard and useSSR hooks with additional options and documentation

30da4 — feat: add new hooks and their metadata

2f161 — feat: add useConferenceSystem, useKbd, useMediaQuality, useNetworkInformation, usePortal, useRoleGuard, useScreenShare, useSymbol hooks

Built with Love • © 2026