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/bluetooth-sdk@0.4.5bunx 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:
The plugin configures native module registration and the companion Android lc3Lib module during prebuild. On iOS it also adds two pods to the Podfile that CocoaPods trunk cannot supply: FluidAudio, which runs the Parakeet speech models and is why Expo apps need an iOS deployment target of 17.0, and ONNX Runtime with its Objective-C API (BluetoothSDKOnnxRuntime and BluetoothSDKOnnxRuntimeObjC), from podspecs shipped in the package that take the library from Microsoft’s NuGet release. The node option writes the path of your node binary into ios/.xcode.env.local (NODE_BINARY) and the directory that holds it into the Android Gradle org.gradle.jvmargs (-Dorg.gradle.project.nodePath), so native builds started outside a shell find Node.
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.
Relaunch After iOS Terminates The App
With bluetooth-central in UIBackgroundModes, the SDK creates each glasses and controller Bluetooth connection with a CoreBluetooth restore identifier. When iOS terminates the app for memory pressure, a crash, or the watchdog, those connections stay up in the system. The next peripheral event relaunches the app in the background. The Expo plugin starts React Native off-screen on that launch in release builds; development clients start it through the dev launcher.Call BluetoothSdk.consumeBluetoothRestoreLaunch() at startup. It resolves true once per launch when iOS relaunched the app for a preserved connection. Call connectDefault() then, without waiting for a screen to ask. A force quit from the app switcher drops the preserved state. On Android the call always resolves false.
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: