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:
| Parameter | Required | Type | Description |
|---|---|---|---|
instanceId | string | A 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. | |
onRecordingData | Function | Callback for the recording-data event | |
onRecordingError | Function | Callback for the recording-error event | |
onRecordingStarted | Function | Callback for the recording-started event | |
onRecordingStopped | Function | Callback 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.
| Name | Type | Description |
|---|---|---|
error | boolean | true if any instance has a recording-error. With multiple instances, use useRecording({ instanceId }) for per-instance error state. |
isLocalParticipantRecorded | boolean | true if the local participant is recorded by any instance |
isRecording | boolean | true if any recording instance is active |
layout | Object | Layout of the first active instance. With multiple instances, use useRecording({ instanceId }) for per-instance layout. |
local | boolean | true for local recordings |
recordingId | string | Recording ID of the first active instance. With multiple instances, use useRecording({ instanceId }) for per-instance recording ID. |
recordingStartedDate | Date | Start date of the first active instance. With multiple instances, use useRecording({ instanceId }) for per-instance start date. |
startedBy | string | Starter of the first active instance. With multiple instances, use useRecording({ instanceId }) for per-instance starter. |
startRecording | Function | See daily-js startRecording() |
stopRecording | Function | See daily-js stopRecording() |
type | string | Recording type of the first active instance. With multiple instances, use useRecording({ instanceId }) for per-instance type. |
updateRecording | Function | See daily-js updateRecording() |
With instanceId (per-instance state)
When called with instanceId, the hook returns state for that specific recording instance only.
| Name | Type | Description |
|---|---|---|
error | boolean | true if this instance has a recording error |
errorMsg | string | Error message for this instance, if any |
instanceId | string | The instance ID |
isLocalParticipantRecorded | boolean | Whether the local participant is recorded by this instance |
isRecording | boolean | Whether this instance is currently recording |
layout | Object | The recording layout for this instance |
local | boolean | true if this is a local recording |
recordingId | string | The recording ID for this instance |
recordingStartedDate | Date | When this instance started recording |
startedBy | string | Who started this recording instance |
startRecording | Function | See daily-js startRecording() |
stopRecording | Function | See daily-js stopRecording() |
type | string | The recording type for this instance |
updateRecording | Function | See daily-js updateRecording() |