Type-safe, Promise-based HealthKit bindings for React Native and Expo. Powered by Nitro Modules for exceptional performance.
Install the package
yarn add @kingstinct/react-native-healthkit
Add the Config Plugin to app.json
{
"expo": {
"plugins": [
"@kingstinct/react-native-healthkit"
]
}
}
import { Text, Button, View } from 'react-native'
import { useHealthkitAuthorization } from '@kingstinct/react-native-healthkit'
export default function AuthExample() {
const [authorizationStatus, requestAuthorization] =
useHealthkitAuthorization({
toRead: ['HKQuantityTypeIdentifierBloodGlucose']
})
return (
<View>
<Text>Authorization Status: {authorizationStatus}</Text>
<Button
onPress={requestAuthorization}
title="Request Authorization"
/>
</View>
)
}
import { Text, View } from 'react-native'
import { useMostRecentQuantitySample } from '@kingstinct/react-native-healthkit'
export default function BloodGlucoseMonitor() {
const sample = useMostRecentQuantitySample(
'HKQuantityTypeIdentifierBloodGlucose'
)
return (
<View>
<Text>
Blood Glucose: {sample?.quantity} {sample?.unit}
</Text>
</View>
)
}