Immediate Fix
The most common reason navigator.bluetooth is undefined is that the Web Bluetooth API requires a Secure Context. This means your website must be served over https:// or http://localhost.
If you are testing on a remote server without SSL or using a local IP address like 192.168.1.10, the browser will disable the API for security reasons.
| Checklist Item | Requirement | Action |
|---|---|---|
| Protocol | HTTPS | Install an SSL certificate or use GitHub Pages. |
| Local Testing | localhost | Use http://localhost instead of an IP address. |
| Browser Support | Chromium-based | Use Chrome, Edge, or Opera. Firefox is not supported. |
Check Support in Console
Run this snippet in your browser’s console to verify the status of the API:
if (window.isSecureContext) {
console.log("Secure context: Yes");
console.log("Bluetooth Support:", Boolean(navigator.bluetooth));
} else {
console.log("Secure context: No (Web Bluetooth is disabled)");
}
Technical Explanation
The Web Bluetooth API provides a way for websites to communicate over GATT (Generic Attribute Profile) to devices. Because this involves direct hardware access, browsers enforce strict security policies.
In Chromium-based browsers, the navigator.bluetooth object is hidden entirely if the origin is not secure. This prevents man-in-the-middle attacks from intercepting sensitive biometric or device data.
Furthermore, Web Bluetooth must be triggered by a User Gesture, such as a click or touch event. You cannot call navigator.bluetooth.requestDevice() on page load.

Alternative Methods
If you must test on a non-secure environment or an unsupported browser, you can use flags or polyfills to bypass the restriction temporarily.
Enable Experimental Flags
For development purposes, you can force Chrome to treat specific origins as secure. Navigate to the following URL in Chrome:
chrome://flags/#unsafely-treat-insecure-origin-as-secure
Add your development URL (e.g., http://192.168.1.5:8080) to the list, set the flag to “Enabled,” and restart the browser.
Testing on Mobile
If you are testing on iOS, standard Safari does not support Web Bluetooth. You will need to download the Bluefy browser or the WebBLE app to access the navigator.bluetooth object on Apple mobile devices.
On Android, ensure that Location Services are enabled. Chrome requires location permissions to scan for Bluetooth Low Energy (BLE) devices, even if your app doesn’t use GPS data.