Skip to main content
The useOdyssey hook provides a convenient way to manage the Odyssey client lifecycle and state in React applications.

Usage

Parameters

Return Value

The hook returns an OdysseyClient object with the following properties and methods:

Methods

State

Basic Example

Complete Example

Tips

The hook automatically manages cleanup when the component unmounts, but it’s good practice to explicitly call disconnect() in your cleanup function.
  • Always call connect() in a useEffect hook
  • Use the returned status and error properties to show connection state to users
  • The isConnected property is useful for disabling buttons until the connection is ready

Broadcast

The React hook supports Broadcast mode, allowing a single running stream to be shared with multiple connected clients. To enable Broadcast, pass broadcast: true when starting a stream. Playback details will be delivered through the onBroadcastReady handler.

Streamer Example

Spectator Example

To connect as a spectator, use the WebRTC URL and spectator token provided by onBroadcastReady.
Broadcast provides shared playback of a single running stream.If your application allows multiple users to send prompts to the same stream, that behavior is implemented through a custom orchestration layer in your application. Broadcast itself does not coordinate or arbitrate user input.