Skip to content

useDebug ​

useDebug() ​

ts
function useDebug(options): object;

Debug hook that snapshots the player's state and logs each change.

Every entry is also written to the console. The log is shared by every mounted useDebug: two mounted instances each log the same change, and clear empties it for all of them. Position changes under 2 seconds are not logged. enabled: false stops only the logging; the hook still subscribes to the state hooks, useProgress among them, and re-renders on every change, so remove it from production code rather than disabling it.

Parameters ​

ParameterTypeDescription
optionsDebugOptionsLogging options

Returns ​

object

state, a summary snapshot (the queue as comma-joined srcs, the content as its title, errors as their messages); logs, the last 100 { timestamp, elapsed, type, message } entries; and clear, which empties the log.

NameTypeDefault value
stateDebugState-
logsDebugLogEntry[]-
clear()() => voidclearDebugLogs

Example ​

tsx
function MyScreen() {
  const debug = useDebug()
  // debug.state - current state
  // debug.logs - log history
  // debug.clear() - clear logs
}

// With metadata logging for live streams
function RadioScreen() {
  const debug = useDebug({ metadata: true })
}