SSE Hooks

useScreenShare

GitHub
Custom hook that captures the user's screen or specific application window. It handles permission errors, stream management, native stop events, and cleanup.

Installation

npx sse-hooks add use-screen-share

Usage

example.ts
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

Prop Default Type
initialOptions

DEFAULT_OPTIONS

UseScreenShareOptions

The initial options for screen sharing (video/audio).

Returns

Return Value Default Type
error-

string | null

isLoading-

boolean

isSupported-

boolean

startCapture-

(options: UseScreenShareOptions) => Promise<void>

stopCapture-

() => void

stream-

MediaStream | null

Types Aliases

No specific type aliases defined for this component.

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