JavaScript Navigator bluetooth Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Experimental

What You’ll Learn

navigator.bluetooth returns a Bluetooth object — the entry point to Web Bluetooth. Learn secure-context rules, feature detection, getAvailability(), how requestDevice() works, five examples, and try-it labs.

01

Kind

Read-only property

02

Returns

Bluetooth

03

Status

Experimental

04

Context

Secure (HTTPS)

05

Baseline

Not yet

06

Key methods

getAvailability

Introduction

Web Bluetooth lets a page talk to nearby Bluetooth Low Energy (BLE) devices — heart-rate monitors, bulbs, sensors — after the user picks a device in a browser chooser.

Your starting point is navigator.bluetooth. When the API exists, that property returns a Bluetooth object with methods such as getAvailability() and requestDevice().

💡
User gesture required

requestDevice() must run from a click (or similar user activation). Browsers block silent device prompts for privacy.

Understanding the bluetooth Property

navigator.bluetooth is read-only. You do not assign to it — you call methods on the object it returns.

  • getAvailability() — Promise<boolean>: can this UA support Bluetooth?
  • requestDevice(options) — Promise<BluetoothDevice>: user picks a device.
  • getDevices() — previously permitted devices for this origin (where supported).
  • Requires HTTPS (or localhost) and explicit user permission via the chooser.

📝 Syntax

General form of the property:

JavaScript
navigator.bluetooth

Value

  • A Bluetooth object for the current document (when supported).

Common patterns

JavaScript
if (!("bluetooth" in navigator)) {
  console.log("Web Bluetooth not available");
} else {
  const ok = await navigator.bluetooth.getAvailability();
  console.log("available:", ok);

  // From a button click:
  // const device = await navigator.bluetooth.requestDevice({
  //   acceptAllDevices: true
  // });
}

⚡ Quick Reference

GoalCode
Feature detect"bluetooth" in navigator
Secure page?window.isSecureContext
Hardware available?await navigator.bluetooth.getAvailability()
Pick a deviceawait navigator.bluetooth.requestDevice(opts)
When to requestInside a click handler
Missing APIShow fallback UI — do not throw

🔍 At a Glance

Four facts to remember about navigator.bluetooth.

Returns
Bluetooth

API entry

Status
experimental

Not Baseline

HTTPS
required

Secure context

Chooser
user click

requestDevice

📋 Detect vs availability vs request

CheckWhat it answersExample
"bluetooth" in navigatorIs the Web Bluetooth API present?API exists in this browser
isSecureContextAre we on HTTPS / localhost?Required for the API
getAvailability()Can Bluetooth be used right now?Adapter / UA policy
requestDevice()User-approved device accessOpens chooser UI

Examples Gallery

Examples follow MDN Navigator.bluetooth / Web Bluetooth patterns with safe detection. Use View Output or Try It Yourself for each case.

📚 Getting Started

Detect the API and confirm a secure context.

Example 1 — Feature Detection

Check whether navigator.bluetooth exists.

JavaScript
const supported = "bluetooth" in navigator;
console.log(supported ? "bluetooth available" : "bluetooth missing");
Try It Yourself

How It Works

Never call navigator.bluetooth.* without this check — unsupported browsers throw.

Example 2 — Secure Context Check

Web Bluetooth needs HTTPS (or localhost).

JavaScript
const lines = [
  "isSecureContext: " + window.isSecureContext,
  "bluetooth: " + ("bluetooth" in navigator ? "present" : "absent")
];
console.log(lines.join("\n"));
Try It Yourself

How It Works

Even on HTTPS, many browsers still omit the property. Secure context is necessary but not sufficient.

📈 Practical Patterns

Availability, requestDevice shape, and a safe helper.

Example 3 — getAvailability()

Ask whether the user agent can support Bluetooth right now.

JavaScript
async function checkBt() {
  if (!("bluetooth" in navigator)) {
    return "Web Bluetooth API missing";
  }
  const ok = await navigator.bluetooth.getAvailability();
  return "getAvailability: " + ok;
}

checkBt().then(console.log);
Try It Yourself

How It Works

MDN notes some UAs let users configure what getAvailability() returns.

Example 4 — requestDevice() Pattern

Call only from a button click; handle cancel/errors.

JavaScript
async function onConnectClick() {
  if (!("bluetooth" in navigator)) {
    return "Web Bluetooth not supported";
  }
  try {
    const device = await navigator.bluetooth.requestDevice({
      acceptAllDevices: true
    });
    return "selected: " + (device.name || "(unnamed)");
  } catch (err) {
    return "requestDevice failed: " + err.name;
  }
}

// Wire to a button in Try It — do not auto-run without a gesture
Try It Yourself

How It Works

Production apps usually filter by services (filters / optionalServices) instead of acceptAllDevices.

Example 5 — Safe Status Helper

Combine detection, secure context, and availability into one result.

JavaScript
async function bluetoothStatus() {
  if (!window.isSecureContext) {
    return { ok: false, reason: "insecure-context" };
  }
  if (!("bluetooth" in navigator)) {
    return { ok: false, reason: "unsupported" };
  }
  const available = await navigator.bluetooth.getAvailability();
  return { ok: available, reason: available ? "ready" : "unavailable" };
}

bluetoothStatus().then((r) => console.log(JSON.stringify(r)));
Try It Yourself

How It Works

Use the reason field to show accurate UI: upgrade HTTPS, unsupported browser, or turn on Bluetooth.

🚀 Common Use Cases

  • Fitness / health — heart-rate and cadence sensors over BLE.
  • Smart home demos — bulbs and switches after user selection.
  • Industrial / IoT tools — configure nearby devices from a web UI.
  • Progressive enhancement — show Connect only when the API exists.
  • Not universal — provide non-Bluetooth alternatives for Safari/Firefox users.

🧠 How navigator.bluetooth Works

1

Detect + secure context

Confirm API presence and HTTPS / localhost.

Detect
2

Check availability

getAvailability() reports whether Bluetooth can be used.

Ready?
3

User picks a device

requestDevice() opens the chooser from a click.

Permission
4

Use BluetoothDevice

Connect to GATT services/characteristics for your accessory.

📝 Notes

  • Experimental and not Baseline — support is limited.
  • Secure context required (HTTPS / localhost).
  • requestDevice needs a user gesture and shows a chooser.
  • Safari and Firefox typically do not expose this API for general web use.
  • Related: audioSession, Window, JavaScript hub.

Limited Browser Support

navigator.bluetooth is Experimental and not Baseline. Chromium-based browsers historically lead support; Safari and Firefox generally do not expose Web Bluetooth for typical sites. Always feature-detect.

Experimental · Not Baseline

Navigator.bluetooth

Use Web Bluetooth only as progressive enhancement on supporting Chromium builds over HTTPS.

Limited Not Baseline
Google Chrome Web Bluetooth on supported desktop/Android builds (check MDN)
Limited
Microsoft Edge Chromium Edge — follow Chrome Web Bluetooth status
Limited
Opera Chromium-based — check current compat
Limited
Mozilla Firefox Not available for typical web content
Unavailable
Apple Safari Not available for typical web content
Unavailable
Internet Explorer No Web Bluetooth API
Unavailable
bluetooth Limited

Bottom line: Detect navigator.bluetooth, require HTTPS, and offer non-Bluetooth fallbacks for unsupported browsers.

Conclusion

navigator.bluetooth is the experimental entry point to Web Bluetooth. Feature-detect it, serve over HTTPS, check getAvailability(), and only call requestDevice() from a user click — with a fallback when the API is missing.

Continue with buildID, Window methods, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect before every Bluetooth call
  • Serve pages over HTTPS
  • Call requestDevice from a button click
  • Filter devices by services when possible
  • Provide a clear unsupported-browser message

❌ Don’t

  • Assume Baseline support across browsers
  • Auto-open the device chooser on page load
  • Ignore secure-context failures
  • Require Bluetooth for core site features
  • Skip error handling for user cancel

Key Takeaways

Knowledge Unlocked

Five things to remember about bluetooth

Experimental Web Bluetooth entry — detect, HTTPS, user gesture.

5
Core concepts
🧪 02

Status

experimental

Caution
🔒 03

HTTPS

secure context

Security
🔍 04

Availability

getAvailability

Check
🖱 05

Chooser

requestDevice

Click

❓ Frequently Asked Questions

It is a read-only Navigator property that returns a Bluetooth object for the current document. That object is the entry point to the Web Bluetooth API (availability checks and device requests).
Yes. MDN marks it Experimental and not Baseline. Support is limited — always feature-detect and check compatibility before production use.
Yes. It is available only in secure contexts (HTTPS or localhost) in supporting browsers.
If navigator.bluetooth exists, call await navigator.bluetooth.getAvailability() which resolves to a boolean. Some browsers also let users configure what that method returns.
Call navigator.bluetooth.requestDevice(options) from a user gesture (for example a button click). It opens a chooser and resolves to a BluetoothDevice when the user picks a device.
No. The property is read-only. You use methods on the returned Bluetooth object such as getAvailability() and requestDevice().
Did you know?

Web Bluetooth is designed around user choice: the browser chooser is the permission UI. Sites cannot silently scan and connect to arbitrary nearby devices without that step.

Learn buildID Next

Non-standard Navigator build identifier string.

buildID →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful