File: pedometer.md | Updated: 11/15/2025
Hide navigation
Search
Ctrl K
Home Guides EAS Reference Learn
Reference version
SDK 52
Archive Expo Snack Discord and Forums Newsletter
Expo PedometerA library that provides access to the device's pedometer sensor.
Android
iOS
Bundled version:
~14.0.2
Copy page
Pedometer from expo-sensors uses the system hardware.Sensor on Android and Core Motion on iOS to get the user's step count, and also allows you to subscribe to pedometer updates.
Terminal
Copy
- npx expo install expo-sensors
If you are installing this in an existing React Native app
, make sure to install expo
in your project.
Pedometer
Copy
Open in Snack
import { useState, useEffect } from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { Pedometer } from 'expo-sensors'; export default function App() { const [isPedometerAvailable, setIsPedometerAvailable] = useState('checking'); const [pastStepCount, setPastStepCount] = useState(0); const [currentStepCount, setCurrentStepCount] = useState(0); const subscribe = async () => { const isAvailable = await Pedometer.isAvailableAsync(); setIsPedometerAvailable(String(isAvailable)); if (isAvailable) { const end = new Date(); const start = new Date(); start.setDate(end.getDate() - 1); const pastStepCountResult = await Pedometer.getStepCountAsync(start, end); if (pastStepCountResult) { setPastStepCount(pastStepCountResult.steps); } return Pedometer.watchStepCount(result => { setCurrentStepCount(result.steps); }); } }; useEffect(() => { const subscription = subscribe(); return () => subscription && subscription.remove(); }, []); return ( <View style={styles.container}> <Text>Pedometer.isAvailableAsync(): {isPedometerAvailable}</Text> <Text>Steps taken in the last 24 hours: {pastStepCount}</Text> <Text>Walk! And watch this go up: {currentStepCount}</Text> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, marginTop: 15, alignItems: 'center', justifyContent: 'center', }, });
Show More
import { Pedometer } from 'expo-sensors';
Pedometer.getPermissionsAsync()Android
iOS
Checks user's permissions for accessing pedometer.
Returns:
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) <PermissionResponse>
Pedometer.getStepCountAsync(start, end)iOS
| Parameter | Type | Description |
| --- | --- | --- |
| start | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) | A date indicating the start of the range over which to measure steps. |
| end | [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) | A date indicating the end of the range over which to measure steps. |
Get the step count between two dates.
Returns:
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) <[PedometerResult](https://docs.expo.dev/versions/v52.0.0/sdk/pedometer#pedometerresult) >
Returns a promise that fulfills with a PedometerResult
.
As Apple documentation states :
Only the past seven days worth of data is stored and available for you to retrieve. Specifying a start date that is more than seven days in the past returns only the available data.
Pedometer.isAvailableAsync()Android
iOS
Returns whether the pedometer is enabled on the device.
Returns:
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) <boolean>
Returns a promise that fulfills with a boolean, indicating whether the pedometer is available on this device.
Pedometer.requestPermissionsAsync()Android
iOS
Asks the user to grant permissions for accessing pedometer.
Returns:
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) <PermissionResponse>
Pedometer.watchStepCount(callback)Android
iOS
| Parameter | Type | Description |
| --- | --- | --- |
| callback | [PedometerUpdateCallback](https://docs.expo.dev/versions/v52.0.0/sdk/pedometer#pedometerupdatecallback) | A callback that is invoked when new step count data is available. The callback is provided with a single argument that is PedometerResult<br>. |
Subscribe to pedometer updates.
Returns:
EventSubscription
Returns a Subscription
that enables you to call remove() when you would like to unsubscribe the listener.
Pedometer updates will not be delivered while the app is in the background. As an alternative, on Android, use another solution based on
Health Connect API. On iOS, thegetStepCountAsyncmethod can be used to get the step count between two dates.
PermissionResponseAndroid
iOS
An object obtained by permissions get and request functions.
| Property | Type | Description |
| --- | --- | --- |
| canAskAgain | boolean | Indicates if user can be asked again for specific permission. If not, one should be directed to the Settings app in order to enable/disable the permission. |
| expires | [PermissionExpiration](https://docs.expo.dev/versions/v52.0.0/sdk/pedometer#permissionexpiration) | Determines time when the permission expires. |
| granted | boolean | A convenience boolean that indicates if the permission is granted. |
| status | [PermissionStatus](https://docs.expo.dev/versions/v52.0.0/sdk/pedometer#permissionstatus) | Determines the status of the permission. |
PedometerResultAndroid
iOS
| Property | Type | Description |
| --- | --- | --- |
| steps | number | Number of steps taken between the given dates. |
PedometerUpdateCallback(result)Android
iOS
Callback function providing event result as an argument.
| Parameter | Type |
| --- | --- |
| result | [PedometerResult](https://docs.expo.dev/versions/v52.0.0/sdk/pedometer#pedometerresult) |
Returns:
void
PermissionExpirationAndroid
iOS
Literal Type: union
Permission expiration time. Currently, all permissions are granted permanently.
Acceptable values are: 'never' | number
SubscriptionAndroid
iOS
A subscription object that allows to conveniently remove an event listener from the emitter.
| Property | Type | Description |
| --- | --- | --- |
| remove | () => void | Removes an event listener for which the subscription has been created. After calling this function, the listener will no longer receive any events from the emitter. |
PermissionStatusAndroid
iOS
DENIEDPermissionStatus.DENIED = "denied"
User has denied the permission.
GRANTEDPermissionStatus.GRANTED = "granted"
User has granted the permission.
UNDETERMINEDPermissionStatus.UNDETERMINED = "undetermined"
User hasn't granted or denied the permission yet.