Bluetooth hooks
Import Bluetooth hooks from @ovok/native/bt-management. Runtime hooks must render beneath BTProvider; they read the runtime owned by that provider.
Runtime hooks
| Hook | Returns | Use it for |
|---|---|---|
useNearbyDevices() | devices and pair(id) | Read discovered managed devices and connect to a device by its runtime ID. |
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 events | Observe 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. |
useRuntimeEvent(event, callback) | — | Subscribe to a typed runtime event for a focused integration. |
useBluetoothRuntime() | runtime object | Advanced 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
useBluetoothState({ bleManager?, requestPermission? })observes the radio state and returnson,off,unauthorized, orunsupportedplus a permission request function.useRequestPermissions({ onAccessPermissionChanged? })requests the platform permission used byBTProviderand reports whether access was granted.useHealthImportis 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.