useOdyssey hook provides a convenient way to manage the Odyssey client lifecycle and state in React applications.
Usage
Parameters
Return Value
The hook returns anOdysseyClient 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 auseEffecthook - Use the returned
statusanderrorproperties to show connection state to users - The
isConnectedproperty 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, passbroadcast: 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 byonBroadcastReady.
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.