Search code examples
web-bluetooth

Is it possible to persist a Bluetooth LE connection on browser refresh


Is it possible to persist a Bluetooth LE connection on browser refresh? Or at least minimize the pairing time?


Solution

  • Eventually navigator.permissions.query would support this. Sample code from Web Bluetooth Specification

    navigator.permissions.query({
      name: "bluetooth",
      deviceId: sessionStorage.lastDevice,
    }).then(result => {
      if (result.devices.length == 1) {
        return result.devices[0];
      } else {
        throw new DOMException("Lost permission", "NotFoundError");
      }
    }).then(...);
    

    However, no browser currently implements this.

    As of Q3 2017 the chromium implementation is actively working on Web Bluetooth but not this feature.