Hardware Web API feature detection

hardware web geolocation ble webusb

This example contains feature detection code in JavaScript. Load the HTML file file via a server on different browsers to see whether geolocation, Web BLE and Web USB are supported.

Chrome

HW APIs availability on Chrome browser

Safari

HW APIs availability on Safari browser

Code

Download code View demo
<p>Please open the browser dev console to view whether geolocation, web ble and web usb are available in this browser.</p>

<script>
  if (navigator.geolocation) {
    console.log('%c Geolocation API is available in this browser!', 'color: #006400')
  } else {
    console.log('%c Geolocation API is not available in this browser.', 'color: #8b0000')
  }

  if (navigator.bluetooth) {
    console.log('%c Web Bluetooth API is available in this browser!', 'color: #006400')
  } else {
    console.log('%c Web Bluetooth API is not available in this browser.', 'color: #8b0000')
  }

  if (navigator.usb) {
    console.log('%c Web USB API is available in this browser!', 'color: #006400')
  } else {
    console.log('%c Web USB API is not available in this browser.', 'color: #8b0000')
  }
</script>

References