const btPermission = await navigator.permissions.query({ name: "bluetooth" });
if (btPermission.state !== "denied") {
// Do something
}Web Bluetooth API / notebook
Web Bluetooth API
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const btPermission = await navigator.permissions.query({
name: "bluetooth",
deviceId: sessionStorage.lastDevice,
});
if (result.devices.length === 1) {
return result.devices[0];
} else {
throw new DOMException("Lost permission", "NotFoundError");
}