Skip to main content

Get started

Requirements

Make sure you have React Native version 0.71 or higher with the latest patch installed to use v2 of React Native Health Connect.

  • Health Connect needs to be installed on the user's device. Starting from Android 14 (Upside Down Cake), Health Connect is part of the Android Framework. Read more here.
  • Health Connect API requires minSdkVersion=26 (Android Oreo / 8.0).
  • If you are planning to release your app on Google Play, you must declare your Health Connect data access. This is now done in the Play Console — the standalone Google Form previously used for these requests is being retired on September 3rd, 2026, and all submissions go through the Play Console instead. See Google's health apps declaration guidance, or how to sign up for a Play Console developer account if you do not have one yet. Approval can take up to 7 days.
  • Approval does not grant you immediate access to Health Connect. A whitelist must propagate to the Health Connect servers, which take an additional 5-7 business days. The whitelist is updated every Monday according to Google Fit AHP support.
note

Health Connect does not appear on the Home screen by default. To open Health Connect, go to Settings > Apps > Health Connect, or add Health Connect to your Quick Settings menu.

note

Health Connect requires the user to have screen lock enabled with a PIN, pattern, or password so that the health data being stored within Health connect is protected from malicious parties while the device is locked. Please go to Settings > Security > Screen lock to set a screen lock.

Installation

To install react-native-health-connect, use the following command:

npm install react-native-health-connect

If you are using React Native CLI template, for version 2 onwards, please add the following code into your MainActivity.kt within the onCreate method:

package com.healthconnectexample

+ import android.os.Bundle
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
+ import dev.matinzd.healthconnect.permissions.HealthConnectPermissionDelegate

class MainActivity : ReactActivity() {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "HealthConnectExample"

+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ // In order to handle permission contract results, we need to set the permission delegate.
+ HealthConnectPermissionDelegate.setPermissionDelegate(this)
+ }

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
*/
override fun createReactActivityDelegate(): ReactActivityDelegate =
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
}

If you are using a Java based react native project, please add the following code into your MainActivity.java within the onCreate method:

package com.healthconnectexample

+ import android.os.Bundle
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
+ import dev.matinzd.healthconnect.permissions.HealthConnectPermissionDelegate

class MainActivity : ReactActivity() {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "HealthConnectExample"

+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ // In order to handle permission contract results, we need to set the permission delegate.
+ HealthConnectPermissionDelegate.INSTANCE.setPermissionDelegate(this, "com.google.android.apps.healthdata");
+ }

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
*/
override fun createReactActivityDelegate(): ReactActivityDelegate =
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
}

You also need to setup permissions in your AndroidManifest.xml file. For more information, check here.

Expo installation

This package cannot be used in the Expo Go app, but it can be used with custom managed apps.

note

As of v4, the Expo integration ships inside react-native-health-connect. There is no longer a separate expo-health-connect package to install — see Migrating from expo-health-connect below.

Install the package with yarn, npm, or expo install:

npm install react-native-health-connect
npm install expo-build-properties --save-dev

Then add the config plugin to the plugins array of your app.json or app.config.js:

{
"expo": {
...
"plugins": [
"react-native-health-connect",
[
"expo-build-properties",
{
"android": {
"compileSdkVersion": 36,
"targetSdkVersion": 36,
"minSdkVersion": 26
}
}
]
]
...
}
}

You do not need to touch MainActivity in an Expo project. The permission delegate shown in the React Native CLI section above is registered automatically by the Expo module bundled with this package.

Then rebuild the native app:

  • Run expo prebuild
  • Rebuild the app
    • yarn android -- Build on Android.

If the project doesn't build correctly with yarn android, please file an issue and try setting the project up manually.

Finally create a new EAS development build

eas build --profile development --platform android

A complete working Expo app lives in example-expo/.

Migrating from expo-health-connect

expo-health-connect is deprecated; everything it did is now part of this package.

  1. Remove it: npm uninstall expo-health-connect
  2. In your app.json plugins array, replace "expo-health-connect" with "react-native-health-connect".
  3. Re-run npx expo prebuild --clean.

If you leave expo-health-connect installed, the Android build fails with a duplicate expo.modules.healthconnect.HealthConnectPackage class — both packages would contribute the same Kotlin class. Removing the old package resolves it.

Example

A quick example at a glance:

import {
initialize,
requestPermission,
readRecords,
} from 'react-native-health-connect';

const readSampleData = async () => {
// initialize the client
const isInitialized = await initialize();

// request permissions
const grantedPermissions = await requestPermission([
{ accessType: 'read', recordType: 'ActiveCaloriesBurned' },
]);

// check if granted

const { records } = await readRecords('ActiveCaloriesBurned', {
timeRangeFilter: {
operator: 'between',
startTime: '2023-01-09T12:00:00.405Z',
endTime: '2023-01-09T23:53:15.405Z',
},
});
// {
// records: [
// {
// startTime: '2023-01-09T12:00:00.405Z',
// endTime: '2023-01-09T23:53:15.405Z',
// energy: {
// inCalories: 15000000,
// inJoules: 62760000.00989097,
// inKilojoules: 62760.00000989097,
// inKilocalories: 15000,
// },
// metadata: {
// id: '239a8cfd-990d-42fc-bffc-c494b829e8e1',
// lastModifiedTime: '2023-01-17T21:06:23.335Z',
// clientRecordId: null,
// dataOrigin: 'com.healthconnectexample',
// clientRecordVersion: 0,
// device: 0,
// },
// },
// ],
// }
};