Use @glassly/bluetooth-sdk from a React Native or Expo development build.
React Native apps use the JavaScript package @glassly/bluetooth-sdk. The package contains native Android and iOS code, so it must run in a development build or production native build.
Expo Go cannot load @glassly/bluetooth-sdk because Expo Go does not include the SDK’s native modules.
bun add @glassly/[email protected]bunx expo install expo-build-properties
Configure The Expo Plugin
Add the SDK plugin and Android native-library packaging rules to your Expo app config. In most Expo apps this is the root app.json; in TypeScript-configured apps it is usually the root app.config.ts. Merge these keys into the existing top-level expo object instead of creating a second config file or replacing unrelated settings:
Use a physical phone for Bluetooth, camera, microphone, direct phone photo, and direct phone WebRTC testing.
Permissions
Configure permissions in the same root Expo app config. If your app already has android.permissions or ios.infoPlist, append or merge these values:
{ "expo": { "android": { "permissions": [ "android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_CONNECT", "android.permission.ACCESS_FINE_LOCATION", "android.permission.RECORD_AUDIO", "android.permission.POST_NOTIFICATIONS" ] }, "ios": { "infoPlist": { "NSBluetoothAlwaysUsageDescription": "This app connects to your smart glasses over Bluetooth.", "NSMicrophoneUsageDescription": "This app uses the microphone when you enable audio features.", "NSLocalNetworkUsageDescription": "This app can connect to optional local demo servers on your network." } } }}
Background Operation On iOS
If your React Native app needs BLE to keep running while the phone is locked or the app is backgrounded, add bluetooth-central to ios.infoPlist.UIBackgroundModes. If the app also keeps microphone capture or an audio session active in the background, add audio too:
{ "expo": { "ios": { "infoPlist": { "UIBackgroundModes": [ "bluetooth-central", "audio" ], "NSBluetoothAlwaysUsageDescription": "This app connects to your smart glasses over Bluetooth.", "NSMicrophoneUsageDescription": "This app uses the microphone when you enable audio features." } } }}
Configure the iOS audio session before continuous mic capture. If your app does not already depend on expo-audio, install it with bunx expo install expo-audio. Then call setAudioModeAsync once during app startup or before enabling the microphone:
Start continuous microphone capture while the app is foregrounded; iOS background mode lets an active session continue, but the SDK does not start the phone microphone from the background.Use audio background mode only when the app genuinely records or plays audio in the background. bluetooth-central is the BLE requirement; audio is the audio-session requirement for continuous mic/audio behavior.
This SDK version does not enable terminated-app Core Bluetooth state restoration with CBCentralManagerOptionRestoreIdentifierKey. If iOS terminates the app, relaunch the app and reconnect from your normal startup flow.
Use the React hooks below to render connection and status state in components.
React Hooks
React Native apps can use the optional hooks subpath for common lifecycle
plumbing while keeping the root SDK available for direct commands:
Hook
Use when
useBluetooth
You want one React session object for status, scan, connect/disconnect, default-device state, and gallery mode.
useBluetoothScan
You want a focused scan picker without the full connection/session helper.
useBluetoothEvent
You want React-managed subscription cleanup for hardware events such as button presses, touch, battery, Wi-Fi, hotspot, photo, stream, speaking, or microphone events.
The hooks do not request Android permissions or choose a persistence package for
you. Ask for permissions in your app before calling scan/connect actions, and
pass a defaultDeviceStorage adapter to useBluetooth if you want to
restore a default device across app restarts.
Status Shape
React Native exposes glassly.glasses.connection as a discriminated union:
Use glassly.glasses.connection.state for link-layer progress. fullyBooted only exists when state === 'connected'.Use useBluetooth() as the React status API for connection, battery, Wi-Fi, hotspot, scan, and SDK runtime state. setGalleryModeEnabled(...) resolves with the ASG SettingsAckSuccessEvent and rejects failure statuses, glassly.sdk.galleryMode.enabled reflects the acknowledged gallery-mode setting, and glassly.sdk.galleryMode.applying is true while that ASG response is in flight.
Default Device
React Native apps should persist their own default-device record if they want connectDefault() to work after restart: