useRecording

useRecording(params?): Object

useRecording returns the state and information of a recording in progress, along with helper functions for daily-js recording methods.

Accepts optional callbacks for recording events.

When multiple recordings are running concurrently (see multi-instance recording), 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 useRecordingInstances.

Params (optional)

An object with the following properties:

ParameterRequiredTypeDescription
instanceIdstringA valid UUID. When provided, returns state for a specific recording instance and filters event callbacks to only fire for that instance. See multi-instance recording.
onRecordingDataFunctionCallback for the recording-data event
onRecordingErrorFunctionCallback for the recording-error event
onRecordingStartedFunctionCallback for the recording-started event
onRecordingStoppedFunctionCallback for the recording-stopped event

Return type

An object with the following properties:

Without instanceId (aggregate state)

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

NameTypeDescription
errorbooleantrue if any instance has a recording-error. With multiple instances, use useRecording({ instanceId }) for per-instance error state.
isLocalParticipantRecordedbooleantrue if the local participant is recorded by any instance
isRecordingbooleantrue if any recording instance is active
layoutObjectLayout of the first active instance. With multiple instances, use useRecording({ instanceId }) for per-instance layout.
localbooleantrue for local recordings
recordingIdstringRecording ID of the first active instance. With multiple instances, use useRecording({ instanceId }) for per-instance recording ID.
recordingStartedDateDateStart date of the first active instance. With multiple instances, use useRecording({ instanceId }) for per-instance start date.
startedBystringStarter of the first active instance. With multiple instances, use useRecording({ instanceId }) for per-instance starter.
startRecordingFunctionSee daily-js startRecording()
stopRecordingFunctionSee daily-js stopRecording()
typestringRecording type of the first active instance. With multiple instances, use useRecording({ instanceId }) for per-instance type.
updateRecordingFunctionSee daily-js updateRecording()

With instanceId (per-instance state)

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

NameTypeDescription
errorbooleantrue if this instance has a recording error
errorMsgstringError message for this instance, if any
instanceIdstringThe instance ID
isLocalParticipantRecordedbooleanWhether the local participant is recorded by this instance
isRecordingbooleanWhether this instance is currently recording
layoutObjectThe recording layout for this instance
localbooleantrue if this is a local recording
recordingIdstringThe recording ID for this instance
recordingStartedDateDateWhen this instance started recording
startedBystringWho started this recording instance
startRecordingFunctionSee daily-js startRecording()
stopRecordingFunctionSee daily-js stopRecording()
typestringThe recording type for this instance
updateRecordingFunctionSee daily-js updateRecording()

Sample code

Basic usage

Multi-instance usage