GuidesComponentsBluetooth management

Bluetooth hooks

React hooks for Bluetooth runtime state, nearby devices, results, pairing, and scan control.

  • Stable unknown
  • Release candidate since 1.16.1-rc.3
  • Development since 1.16.1-dev.2111+9796905

Import Bluetooth hooks from @ovok/native/bt-management. Runtime hooks must render beneath BTProvider; they read the runtime owned by that provider.

Runtime hooks

HookReturnsUse it for
useNearbyDevices()devices and pair(id)Read discovered managed devices and connect to a device by its runtime ID.
useBluetoothState({ bleManager?, requestPermission? })state, permissionStatus, requestPermission(), and openSettings()Observe Bluetooth state and request access from an app-owned action. It does not request permission on mount.
usePairedDevices({ storage, storageKey?, autoPair? })paired, pair(device), and forget(id)Persist remembered device IDs with app-supplied async key-value storage.
useDeviceConnection(id)status and recent eventsObserve one device's status and connection events.
useMeasurements(onResult?, options?)measurements and clear()Collect recent results in component state, deduplicated by result ID.
useScanControl()canControl, pauseScan(), and resumeScan()Pause and resume the provider's scan without unmounting it.
useOpenSeries(manager)the series being recorded, each with its latest valuesShow a streaming device's values before its series is stored. Works with any BTManager, inside or outside BTProvider.
useQueuedResults(coordinator)the current account's results still waitingShow readings that are not saved yet, from a BackgroundSyncCoordinator.
useRuntimeEvent(event, callback)—Subscribe to a typed runtime event for a focused integration.
useBluetoothRuntime()runtime objectAdvanced access to the underlying provider runtime. Prefer the focused hooks above.

usePairedDevices persists device IDs, not credentials. The default storage key is @ovok/native/paired-devices. Supply storage backed by your app's secure or durable storage policy, and call forget when the user removes a device.

useMeasurements supports the policies all, daily-totals-only, and first-reading-per-kind-per-connection. Its in-memory list is capped by maxResults (default 100). For durable application records, persist results from BTProvider.onResult.

Hooks that can run outside BTProvider

  • useRequestPermissions({ onAccessPermissionChanged? }) requests the platform permission used by BTProvider and reports whether access was granted.
  • useHealthImport is a separate health-data integration hook; see the health data guide.

The raw runtime context hook is exported for advanced integrations. Components using it should still be rendered beneath the provider; it throws if no Bluetooth runtime is available.

See BTProvider and the Bluetooth guide.

Last updated on

On this page