Skip to content

useDevice

useDevice(query): Device | null

Defined in: console-sdk/src/react/hooks/useDevice.ts:52

The first device matching query in the deterministic fleet ordering (SDK_PLAN.md §3.6.2), or null when none match — useDevices(query)[0] ?? null over the ONE Device type. A DeviceId selects that exact device; a DeviceQuery returns the first match in fleet order; a null/undefined query returns null (a nullable subject the caller has not resolved yet — §3.2.6). Safe from the first render and referentially stable while the picked record is unchanged (§3.9.1).

When a DeviceQuery matches more than one device the pick is a deliberate, deterministic choice; DEV builds warn so ambiguity surfaces early (tighten the query or render the list with useDevices). Throws OutsideProviderError when no <ConsoleProvider> is above the caller.

DeviceId | DeviceQuery | null | undefined

a device id, a filter object, or null/undefined.

Device | null

the matching Device, or null.

const rower = useDevice({ modality: 'rower', connected: true }); // Device | null
const byId = useDevice(deviceId);