
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
react-web-bluetooth
Advanced tools
This is a package that provides a hooks wrapper around the new Web Bluetooth API
It is an experimental feature implemented under a flag in Chrome. In order to use this feature in Chrome, enable:
chrome://flags/#enable-experimental-web-platform-features
The getDevices
method requires also to enable the new permissions backend experimental feature.
chrome://flags/#enable-web-bluetooth-new-permissions-backend
getDevices
is used to retrieve already paired Bluetooth devices from the browser, for example after a refresh instead of pairing a device again getDevices
can be used to connect to it without pairing.
const { onClick, device } = useRequestDevice({
acceptAllDevices: true,
});
// ...
return <>
{!device && <button onClick={onClick}>Connect</button>}
{device && <span>{device.name}</span>}
</>
useGetServer
Params:
device
: BluetoothDevice
Returns:
server
: BluetoothRemoteGATTServer
useGetCharacteristic
Params:
service
: BluetoothRemoteGATTService
bluetoothCharacteristicUUID
: string
Returns:
characteristic
: BluetoothRemoteGATTCharacteristic
useGetDevices
Returns: devices[]
: BluetoothDevice[]
useRequestDevice
Params:
options
: https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice#parameters
Returns:
onClick
: (event) => void // returns a onClick function that can be used to trigget the browser's pairing window and list the scanned Bluetooth devices.
device
: BluetoothDevice // returns a device chosen from the Bluetooth pairing dialogue.
useGetPrimaryService
Params:
device
: BluetoothDevice
Returns:
service
: BluetoothRemoteGATTService
useReadValue
Params:
characteristic
: BluetoothRemoteGATTCharacteristic
Returns::
value
: DataView
writeValue
Params:
characteristic
: BluetoothRemoteGATTCharacteristic
value
: ArrayBuffer
FAQs
React hooks wrapper for the Web Bluetooth API
We found that react-web-bluetooth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.