WIP: This library is not ready for use in any projects
react-bluetooth
Tools to integrate the current web Bluetooth API spec in your React web applications.
The goal of this project is to create a unified API for working with Bluetooth across browser, iOS, Android, and PWAs.
References
Installation
yarn add react-bluetooth
Usage
Import the library into your JavaScript file:
;
Methods
requestDeviceAsync
requestDeviceAsync options: RequestDeviceOptions = : Promise< | >
Example
try catch
getAvailabilityAsync
getAvailabilityAsync: Promise<boolean>
Returns a boolean that denotes bluetooth availability on the current device. This will also polyfill instances where navigator.bluetooth.getAvailability()
is not supported.
Example
if await Bluetooth.getAvailabilityAsync
getReferringDevice
getReferringDevice: BluetoothDevice | undefined
addPlatformHandler
addPlatformHandlereventName: BluetoothEvent, handler: PlatformHandler: Subscription
Example
;
addEventListener
addEventListener listener: EventListenerOrEventListenerObject, useCapture?: boolean: void
dispatchEvent
dispatchEventevent: Event: boolean
removeEventListener
removeEventListener callback: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean: void
Types
BluetoothEvent
Used with Bluetooth.setPlatformHandler
.
Examples