@sebscode/expo-local-gyro
v0.1.0
Published
Use your MacBook's gyroscope in iOS Simulator. Works with Expo Go.
Maintainers
Readme
expo-local-gyro
Use your MacBook's gyroscope in iOS Simulator. Works with Expo Go.
Quick Start
Install the package
npm install expo-local-gyroRun MacGyroServer on your Mac
sudo MacGyroServerChange your import
// Before import { Gyroscope, Accelerometer } from 'expo-sensors'; // After import { Gyroscope, Accelerometer } from 'expo-local-gyro';That's it. The API is identical to expo-sensors.
How It Works
expo-local-gyro connects to MacGyroServer via WebSocket (localhost:9877) to receive real IMU data from your MacBook's built-in gyroscope and accelerometer. The data is bridged into your React Native app using the same API as expo-sensors.
If MacGyroServer isn't running, the package automatically falls back to expo-sensors — your app continues to work without changes.
API
Same as expo-sensors Gyroscope and Accelerometer:
Gyroscope.addListener(callback)— subscribe to gyroscope dataGyroscope.setUpdateInterval(ms)— set update frequencyGyroscope.isAvailableAsync()— check if sensor is availableAccelerometer.addListener(callback)— subscribe to accelerometer dataAccelerometer.setUpdateInterval(ms)— set update frequencyAccelerometer.isAvailableAsync()— check if sensor is available
All other expo-sensors exports (Barometer, DeviceMotion, Magnetometer, etc.) are re-exported unchanged.
Requirements
- Apple Silicon MacBook (M2 or later) with built-in IMU
- MacGyroServer running with
sudo - iOS Simulator (Xcode)
Note
On Android, web, and real iOS devices, this package is a transparent passthrough to expo-sensors. No WebSocket connection is attempted — it just works as if you imported expo-sensors directly.
