<br />

> [!NOTE]
> **Important:** This API works **only on ChromeOS**.

<br />

<br />

## Description

Use the `chrome.bluetooth` API to connect to a Bluetooth device. All functions report failures via chrome.runtime.lastError.

<br />

<br />

<br />

## Availability

ChromeOS only

<br />

<br />

## Manifest

The following keys must be declared [in the manifest](https://developer.chrome.com/docs/extensions/mv3/manifest) to use this API.
`"bluetooth"`  

<br />

<br />

## Types

### AdapterState

#### Properties

- address string

  The address of the adapter, in the format 'XX:XX:XX:XX:XX:XX'.
- available boolean

  Indicates whether or not the adapter is available (i.e. enabled).
- discovering boolean

  Indicates whether or not the adapter is currently discovering.
- name string

  The human-readable name of the adapter.
- powered boolean

  Indicates whether or not the adapter has power.

### BluetoothFilter

Chrome 67+

#### Properties

- filterType [FilterType](https://developer.chrome.com/docs/apps/reference/bluetooth#type-FilterType) optional

  Type of filter to apply to the device list. Default is all.
- limit number optional

  Maximum number of bluetooth devices to return. Default is 0 (no limit) if unspecified.

### Device

#### Properties

- address string

  The address of the device, in the format 'XX:XX:XX:XX:XX:XX'.
- batteryPercentage number optional
  Chrome 77+

  The remaining battery of the device.
- connectable boolean optional
  Chrome 48+

  Indicates whether the device is connectable.
- connected boolean optional

  Indicates whether the device is currently connected to the system.
- connecting boolean optional
  Chrome 48+

  Indicates whether the device is currently connecting to the system.
- deviceClass number optional

  The class of the device, a bit-field defined by http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband.
- deviceId number optional
- inquiryRssi number optional
  Chrome 44+

  The received signal strength, in dBm. This field is avaliable and valid only during discovery. Outside of discovery it's value is not specified.
- inquiryTxPower number optional
  Chrome 44+

  The transmitted power level. This field is avaliable only for LE devices that include this field in AD. It is avaliable and valid only during discovery.
- name string optional

  The human-readable name of the device.
- paired boolean optional

  Indicates whether or not the device is paired with the system.
- productId number optional
- transport [Transport](https://developer.chrome.com/docs/apps/reference/bluetooth#type-Transport) optional
  Chrome 76+

  The transport type of the bluetooth device.
- type [DeviceType](https://developer.chrome.com/docs/apps/reference/bluetooth#type-DeviceType) optional

  The type of the device, if recognized by Chrome. This is obtained from the `deviceClass` field and only represents a small fraction of the possible device types. When in doubt you should use the `deviceClass` field directly.
- uuids string\[\] optional

  UUIDs of protocols, profiles and services advertised by the device. For classic Bluetooth devices, this list is obtained from EIR data and SDP tables. For Low Energy devices, this list is obtained from AD and GATT primary services. For dual mode devices this may be obtained from both.
- vendorId number optional
- vendorIdSource [VendorIdSource](https://developer.chrome.com/docs/apps/reference/bluetooth#type-VendorIdSource) optional

  The Device ID record of the device, where available.

### DeviceType

Common device types recognized by Chrome.

#### Enum

"computer"   
"phone"   
"modem"   
"audio"   
"carAudio"   
"video"   
"peripheral"   
"joystick"   
"gamepad"   
"keyboard"   
"mouse"   
"tablet"   
"keyboardMouseCombo"   

<br />

### FilterType

Chrome 67+

Types for filtering bluetooth devices.

#### Enum

"all"   
"known"   

<br />

### Transport

Chrome 76+

Transport type of the bluetooth device.

#### Enum

"invalid"   
"classic"   
"le"   
"dual"   

<br />

### VendorIdSource

Allocation authorities for Vendor IDs.

#### Enum

"bluetooth"   
"usb"   

<br />

## Methods

### getAdapterState()

Promise

```typescript
chrome.bluetooth.getAdapterState(
  callback?: function,
): Promise<https://developer.chrome.com/docs/apps/reference/bluetooth#type-AdapterState>
```

Get information about the Bluetooth adapter.

#### Parameters

- callback function optional


  The `callback` parameter looks like:

  ```typescript
  (adapterInfo: AdapterState) => void
  ```

  <br />

  - adapterInfo [AdapterState](https://developer.chrome.com/docs/apps/reference/bluetooth#type-AdapterState)

    Object containing the adapter information.

#### Returns

- Promise\<[AdapterState](https://developer.chrome.com/docs/apps/reference/bluetooth#type-AdapterState)\>
  Chrome 91+


  Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

### getDevice()

Promise

```typescript
chrome.bluetooth.getDevice(
  deviceAddress: string,
  callback?: function,
): Promise<https://developer.chrome.com/docs/apps/reference/bluetooth#type-Device>
```

Get information about a Bluetooth device known to the system.

#### Parameters

- deviceAddress string

  Address of device to get.
- callback function optional


  The `callback` parameter looks like:

  ```typescript
  (deviceInfo: Device) => void
  ```

  <br />

  - deviceInfo [Device](https://developer.chrome.com/docs/apps/reference/bluetooth#type-Device)

    Object containing the device information.

#### Returns

- Promise\<[Device](https://developer.chrome.com/docs/apps/reference/bluetooth#type-Device)\>
  Chrome 91+


  Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

### getDevices()

Promise

```typescript
chrome.bluetooth.getDevices(
  filter?: BluetoothFilter,
  callback?: function,
): Promise<https://developer.chrome.com/docs/apps/reference/bluetooth#type-Device[]>
```

Get a list of Bluetooth devices known to the system, including paired and recently discovered devices.

#### Parameters

- filter [BluetoothFilter](https://developer.chrome.com/docs/apps/reference/bluetooth#type-BluetoothFilter) optional
  Chrome 67+

  Some criteria to filter the list of returned bluetooth devices. If the filter is not set or set to `{}`, returned device list will contain all bluetooth devices. Right now this is only supported in ChromeOS, for other platforms, a full list is returned.
- callback function optional


  The `callback` parameter looks like:

  ```typescript
  (deviceInfos: Device[]) => void
  ```

  <br />

  - deviceInfos [Device](https://developer.chrome.com/docs/apps/reference/bluetooth#type-Device)\[\]

    Array of object containing device information.

#### Returns

- Promise\<[Device](https://developer.chrome.com/docs/apps/reference/bluetooth#type-Device)\[\]\>
  Chrome 91+


  Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

### startDiscovery()

Promise

```typescript
chrome.bluetooth.startDiscovery(
  callback?: function,
): Promise<void>
```

Start discovery. Newly discovered devices will be returned via the onDeviceAdded event. Previously discovered devices already known to the adapter must be obtained using getDevices and will only be updated using the `onDeviceChanged` event if information about them changes.

Discovery will fail to start if this application has already called startDiscovery. Discovery can be resource intensive: stopDiscovery should be called as soon as possible.

#### Parameters

- callback function optional


  The `callback` parameter looks like:

  ```typescript
  () => void
  ```

  <br />

#### Returns

- Promise\<void\>
  Chrome 91+


  Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

### stopDiscovery()

Promise

```typescript
chrome.bluetooth.stopDiscovery(
  callback?: function,
): Promise<void>
```

Stop discovery.

#### Parameters

- callback function optional


  The `callback` parameter looks like:

  ```typescript
  () => void
  ```

  <br />

#### Returns

- Promise\<void\>
  Chrome 91+


  Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

## Events

### onAdapterStateChanged

```typescript
chrome.bluetooth.onAdapterStateChanged.addListener(
  callback: function,
)
```

Fired when the state of the Bluetooth adapter changes.

#### Parameters

- callback function


  The `callback` parameter looks like:

  ```typescript
  (state: AdapterState) => void
  ```

  <br />

  - state [AdapterState](https://developer.chrome.com/docs/apps/reference/bluetooth#type-AdapterState)

### onDeviceAdded

```typescript
chrome.bluetooth.onDeviceAdded.addListener(
  callback: function,
)
```

Fired when information about a new Bluetooth device is available.

#### Parameters

- callback function


  The `callback` parameter looks like:

  ```typescript
  (device: Device) => void
  ```

  <br />

  - device [Device](https://developer.chrome.com/docs/apps/reference/bluetooth#type-Device)

### onDeviceChanged

```typescript
chrome.bluetooth.onDeviceChanged.addListener(
  callback: function,
)
```

Fired when information about a known Bluetooth device has changed.

#### Parameters

- callback function


  The `callback` parameter looks like:

  ```typescript
  (device: Device) => void
  ```

  <br />

  - device [Device](https://developer.chrome.com/docs/apps/reference/bluetooth#type-Device)

### onDeviceRemoved

```typescript
chrome.bluetooth.onDeviceRemoved.addListener(
  callback: function,
)
```

Fired when a Bluetooth device that was previously discovered has been out of range for long enough to be considered unavailable again, and when a paired device is removed.

#### Parameters

- callback function


  The `callback` parameter looks like:

  ```typescript
  (device: Device) => void
  ```

  <br />

  - device [Device](https://developer.chrome.com/docs/apps/reference/bluetooth#type-Device)

<br />