1--- 2title: DeviceMotion 3description: A library that provides access to a device's motion and orientation sensors. 4sourceCodeUrl: 'https://github.com/expo/expo/tree/main/packages/expo-sensors' 5packageName: 'expo-sensors' 6iconUrl: '/static/images/packages/expo-sensors.png' 7--- 8 9import APISection from '~/components/plugins/APISection'; 10import { APIInstallSection } from '~/components/plugins/InstallSection'; 11import PlatformsSection from '~/components/plugins/PlatformsSection'; 12import { 13 ConfigReactNative, 14 ConfigPluginExample, 15 ConfigPluginProperties, 16} from '~/components/plugins/ConfigSection'; 17import { IOSPermissions } from '~/components/plugins/permissions'; 18 19`DeviceMotion` from `expo-sensors` provides access to the device motion and orientation sensors. All data is presented in terms of three axes that run through a device. According to portrait orientation: X runs from left to right, Y from bottom to top and Z perpendicularly through the screen from back to front. 20 21<PlatformsSection android emulator ios simulator web /> 22 23## Installation 24 25<APIInstallSection /> 26 27## Configuration in app.json/app.config.js 28 29You can configure `DeviceMotion` from `expo-sensor` using its built-in [config plugin](/config-plugins/introduction/) if you use config plugins in your project ([EAS Build](/build/introduction) or `npx expo run:[android|ios]`). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect. 30 31<ConfigPluginExample> 32 33```json app.json 34{ 35 "expo": { 36 "plugins": [ 37 [ 38 "expo-sensors", 39 { 40 "motionPermission": "Allow $(PRODUCT_NAME) to access your device motion." 41 } 42 ] 43 ] 44 } 45} 46``` 47 48</ConfigPluginExample> 49 50<ConfigPluginProperties 51 properties={[ 52 { 53 name: 'motionPermission', 54 platform: 'ios', 55 description: 'A string to set the [`NSMotionUsageDescription`](#ios) permission message.', 56 default: '"Allow $(PRODUCT_NAME) to access your device motion"', 57 }, 58 ]} 59/> 60 61<ConfigReactNative> 62 63Learn how to configure the native projects in the [installation instructions in the `expo-sensors` repository](https://github.com/expo/expo/tree/main/packages/expo-sensors#installation-in-bare-react-native-projects). 64 65</ConfigReactNative> 66 67## API 68 69```js 70import { DeviceMotion } from 'expo-sensors'; 71``` 72 73<APISection packageName="expo-device-motion" /> 74 75## Permissions 76 77### iOS 78 79The following usage description keys are used by this library: 80 81<IOSPermissions permissions={['NSMotionUsageDescription']} /> 82