useLiveStreaming

useLiveStreaming(params?) : Object

Returns information about a live stream, along with helper functions that wrap daily-js live streaming-related methods.

useLiveStreaming can also be used to set up optional callbacks for live streaming events.

When multiple live streams are running concurrently (see multi-instance live streaming), you can pass an instanceId to get per-instance state. Without instanceId, the hook returns aggregate state across all instances. For a list of all active instances, see useLiveStreamingInstances.

Params (optional)

ParameterRequiredTypeDescription
instanceIdstringA valid UUID. When provided, returns state for a specific live streaming instance and filters event callbacks to only fire for that instance. See multi-instance live streaming.
onLiveStreamingErrorFunctionCallback for the live-streaming-error event
onLiveStreamingStartedFunctionCallback for the live-streaming-started event
onLiveStreamingStoppedFunctionCallback for the live-streaming-stopped event
onLiveStreamingUpdatedFunctionCallback for the live-streaming-updated event
onLiveStreamingWarningFunctionCallback for the nonfatal-error event with type 'live-streaming-warning'

Return type

An object with the following properties:

Without instanceId (aggregate state)

When called without instanceId, the hook returns aggregate state across all live streaming instances. This works well for single-instance use cases — the scalar fields (errorMsg, layout) reflect the only active instance. With multiple concurrent instances, these fields reflect the first active instance; use useLiveStreaming({ instanceId }) for unambiguous per-instance access.

NameTypeDescription
errorMsgstringError message from the first errored instance. With multiple instances, use useLiveStreaming({ instanceId }) for per-instance error state.
isLiveStreamingbooleantrue if any live streaming instance is active
layoutObjectLayout of the first active instance. With multiple instances, use useLiveStreaming({ instanceId }) for per-instance layout.
startLiveStreamingFunctionSee startLiveStreaming()
stopLiveStreamingFunctionSee stopLiveStreaming()
updateLiveStreamingFunctionSee updateLiveStreaming()

With instanceId (per-instance state)

When called with instanceId, the hook returns state for that specific live streaming instance only.

NameTypeDescription
errorMsgstringError message for this instance, if any
instanceIdstringThe instance ID
isLiveStreamingbooleanWhether this instance is currently live streaming
layoutObjectThe live streaming layout for this instance
startLiveStreamingFunctionSee startLiveStreaming()
stopLiveStreamingFunctionSee stopLiveStreaming()
updateLiveStreamingFunctionSee updateLiveStreaming()

For more on live streaming with Daily, reference our guide.

Sample code

Basic usage

Multi-instance usage