Web Bluetooth API

On this page 7

The Web Bluetooth API is a browser interface that allows a web page to discover, connect to and exchange data with nearby Bluetooth Low Energy (BLE) devices through the Generic Attribute Profile, after the user explicitly selects a device in a browser-controlled chooser. Among Web APIs, it belongs to the group of device access interfaces, alongside WebUSB and the Gamepad API, that bring hardware capabilities once reserved for native apps to the open Web.

Typical uses include configuring fitness sensors, reading environmental monitors, controlling smart lights and updating the firmware of small embedded devices. The API is asynchronous and promise-based, works only in secure contexts (HTTPS), and is available mainly in Chromium-based browsers, which makes browser support one of the first questions in any project.

How the Web Bluetooth API talks to devices

The Web Bluetooth API exposes the GATT client role of Bluetooth Low Energy to JavaScript. A BLE peripheral organizes its data as a hierarchy: a device offers services, each service contains characteristics, and characteristics can carry descriptors. Every service and characteristic is identified by a UUID, either a short number standardized by the Bluetooth SIG or a full 128-bit vendor identifier.

A typical session follows a fixed sequence. The page calls navigator.bluetooth.requestDevice() with filters, the browser shows a chooser, and the user picks a device. The page then connects to the device’s GATT server, obtains the primary service it needs, reads or writes characteristic values as DataView buffers and, where supported, subscribes to notifications that push new values without polling.

The table below maps the main objects of the API to the BLE concepts they represent.

API objectBLE conceptTypical operations
BluetoothDeviceA selected peripheralRead name, connect, watch disconnection
BluetoothRemoteGATTServerThe device’s GATT serverConnect, disconnect, get primary services
BluetoothRemoteGATTServiceA service such as heart rateList and get characteristics
BluetoothRemoteGATTCharacteristicA single data point or controlRead, write, start notifications
BluetoothRemoteGATTDescriptorMetadata about a characteristicRead or write configuration
Core objects of the Web Bluetooth API

Permission model and security safeguards

Because radio access can expose sensitive hardware, the Web Bluetooth API is built around explicit, per-device user consent. A page cannot scan silently or enumerate every device in range. The requestDevice() call must come from a user gesture such as a click, and only the device the user selects becomes visible to the page.

Pages must also declare which services they intend to use, either in the filters or through the optionalServices list, and the browser blocks access to anything undeclared. A blocklist maintained by browser vendors prevents access to services and characteristics that could be abused, such as those used for human interface devices or firmware attacks. The following table summarizes these safeguards.

SafeguardWhat it preventsDeveloper impact
Secure context onlyTampering by network attackersPages must be served over HTTPS
User gesture requirementPop-up choosers without user intentCall requestDevice from a click handler
Device chooserSilent device enumerationThe user, not the page, picks the device
Declared servicesAccess to unrelated functionsList every needed UUID in advance
GATT blocklistUse of dangerous characteristicsSome services are never reachable
Permissions policyUse inside untrusted iframesEmbedded frames need explicit allowance
Security safeguards in Web Bluetooth

Even with these controls, Mozilla and Apple have declined to ship the API, citing concerns about fingerprinting and the attack surface of device firmware. That position is a deliberate policy choice rather than a technical gap, and it shapes where the API can realistically be used.

The Web Bluetooth API is one of several hardware bridges in the browser, and each one targets a different transport. Choosing the right interface depends on how the device connects and whether a standard abstraction already exists.

APITransportTypical devicesAbstraction level
Web Bluetooth APIBluetooth Low Energy GATTSensors, wearables, smart home devicesServices and characteristics
WebUSBUSBMicrocontroller boards, lab instrumentsRaw transfers and endpoints
Web Serial APISerial ports, including USB serialDevelopment boards, modems, printersByte streams
WebHIDHuman interface device protocolSpecialized keyboards, controllersHID reports
Gamepad APIOperating system input layerGame controllersNormalized buttons and axes
Device access APIs in the browser

A key limitation is that Web Bluetooth covers BLE only, not Bluetooth Classic. Audio headsets, older serial adapters and devices that rely on classic profiles such as A2DP or RFCOMM are out of reach. Pages also act strictly as a central device; they cannot advertise themselves as a peripheral.

Browser support and practical implementation

In practice, the Web Bluetooth API is usable in Chrome, Edge, Opera and other Chromium-based browsers on desktop platforms and Android. Support on iOS is effectively absent because all iOS browsers must use the system WebKit engine. Applications should therefore use feature detection by checking for navigator.bluetooth and offer a fallback, such as a native companion app or manual data entry.

Robust implementations handle the realities of radio links. Connections drop when a device moves out of range or enters sleep mode, so code should listen for the gattserverdisconnected event and reconnect with exponential backoff. Writes should respect the attribute payload limit, which is commonly about 20 bytes on older links and larger when a bigger maximum transmission unit is negotiated, and long transfers such as firmware images must be split into chunks.

The decision table below helps match project requirements to an approach.

SituationRecommended approachReason
Configuration tool for BLE sensorsWeb Bluetooth APINo installation, instant updates
Users mainly on iPhonesNative or hybrid appNo Web Bluetooth support on iOS
Bluetooth Classic audio deviceNative appClassic profiles are not exposed
Wired development boardWeb Serial API or WebUSBA USB connection is more reliable
Choosing an approach for Bluetooth device access

Common pitfalls with Web Bluetooth

Most failures come from mismatched expectations about the device or the browser, not from the API itself. The following mistakes appear frequently in early projects.

  • Forgetting optionalServices: services not declared at request time throw a security error later.
  • Calling requestDevice on page load: without a user gesture, the browser rejects the call.
  • Ignoring byte order: many BLE characteristics use little-endian values, so DataView reads need the correct flag.
  • Assuming a persistent connection: devices disconnect to save power, and reconnection logic is mandatory.
  • Testing in one browser only: behavior and supported features differ between platforms and versions.

A plain-language summary

The Web Bluetooth API lets a website talk to small wireless gadgets near you, such as a heart rate strap, a plant sensor or a smart bulb. Normally you would need to install a special app for each gadget. With this feature, a web page can do the job instead.

It always asks first. When the page wants a device, the browser opens its own list, and you choose exactly one gadget to share. Think of it like handing a guest the key to one room rather than the whole house. It works best in Chrome and Edge, and it does not work on iPhones.

An example from practice

A small company that produces Bluetooth Low Energy air quality monitors for classrooms used to ship a separate mobile app just for setup. Teachers struggled to install it on school-managed devices, and every app store update took days to roll out. The company replaced the app with a setup page built on the Web Bluetooth API, served over HTTPS and opened from a link printed on the device.

A teacher opens the page in Chrome on a school laptop, clicks a button labeled with the product name and selects the monitor from the browser chooser. The page reads the current CO2 level, writes the classroom name and a warning threshold of 1,000 ppm to a configuration characteristic, and subscribes to notifications to show live readings. When a firmware update is available, the page sends the image in small chunks and reconnects automatically if the link drops. Setup time fell from about 15 minutes to under 3, and the company kept a short native app only for staff using iPads.