Skip to main content

Function: useMIDIAccess()

function useMIDIAccess(requestOnMount?): object;

Defined in: react/src/hooks/useMIDIAccess.ts:76

Hooks for requesting MIDI access in the browser. The first argument allows you to choose whether to request access on mount.

inputs follows the devices: it changes as one is plugged in or unplugged, so a list of devices needs no statechange listener of its own.

request takes { sysex: true } when the app needs system exclusive messages. Browsers treat that as a separate, more sensitive permission, so ask for it only when it is actually used.

Parameters​

ParameterTypeDefault value
requestOnMountbooleantrue

Returns​

object

error​

error: MIDIAccessError | null;

inputs​

inputs: readonly MIDIInput[];

midiAccess​

midiAccess: MIDIAccess | null;

request​

request: (options?) => void = store.request;

Parameters​

ParameterType
options?MIDIAccessOptions

Returns​

void