useBluetooth
Reactive Web Bluetooth API. Provides the ability to connect and interact with Bluetooth Low Energy peripherals.
Package: @vueuse/core
Category: Browser
Usage
<script setup lang="ts">
import { useBluetooth } from '@vueuse/core'
const {
isSupported,
isConnected,
device,
requestDevice,
server,
error,
} = useBluetooth({
acceptAllDevices: true,
})
</script>
<template>
<button @click="requestDevice()">
Request Bluetooth Device
</button>
<div v-if="error">
Error: {{ error }}
</div>
</template>Options
| Option | Type | Default | Description |
|---|---|---|---|
| acceptAllDevices | boolean |
false | * A boolean value indicating that the requesting script can accept all Bluetooth |
Returns
| Name | Type |
|---|---|
| isSupported | useSupported |
| isConnected | shallowRef |
| requestDevice | Ref |