
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
webbluetooth
Advanced tools
Node.js implementation of the Web Bluetooth Specification
Node.js > v10.16.0, which includes npm
.
$ npm install webbluetooth
See the examples or view the API documentation at:
https://thegecko.github.io/webbluetooth/
The module exports a default navigator.bluetooth
instance, the Bluetooth
class to allow you to instantiate your own bluetooth instances and some helper methods:
To use existing Web Bluetooth scripts, you can simply use the default bluetooth
instance in place of the navigator.bluetooth
object:
const bluetooth = require("webbluetooth").bluetooth;
const device = await bluetooth.requestDevice({
filters:[{ services:[ "heart_rate" ] }]
});
const server = await device.gatt.connect();
...
The first device matching the filters will be returned.
You may want to create your own instance of the Bluetooth
class. For example, to inject a device chooser function or control the referring device:
const Bluetooth = require("webbluetooth").Bluetooth;
const deviceFound = (device, selectFn) => {
// If device can be automatically selected, do so by returning true
if (device.name === "myName") return true;
// Otherwise store the selectFn somewhere and execute it later to select this device
};
const bluetooth = new Bluetooth({ deviceFound });
const device = await bluetooth.requestDevice({
filters:[{ services:[ "heart_rate" ] }]
});
const server = await device.gatt.connect();
...
The Web Bluetooth specification can be found here:
https://webbluetoothcg.github.io/web-bluetooth/
FAQs
Node.js implementation of the Web Bluetooth Specification
The npm package webbluetooth receives a total of 111 weekly downloads. As such, webbluetooth popularity was classified as not popular.
We found that webbluetooth 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.