android-health-connect
npm GitHub
v0.3.18 Published to npm with Trusted Publishing

Health Connect,
native to React Native.

A typed TurboModule for Android Health Connect: permissions, 42 record types, aggregates, changelog sync, and polling that survives the "0 steps on resume" problem.

terminal · npmjs.org
yarn add @solutionforest/android-health-connect
Steps.tsx
const { value, satisfied } = useForegroundPoll(
  () => readSteps({
    timeRangeFilter: timeRangeToday(),
  }),
  {
    ready: (r) => r.records.length > 0,
    timeoutMs: 15_000,
  },
);
42record types
RN 0.84+New Architecture
API 29+Android 10 and up
100%line coverage · strict TS
Features

Everything Health Connect exposes.

One package covers the whole Jetpack SDK surface, with TypeScript types that mirror Health Connect records one-to-one.

01

Permissions

ensurePermissions requests what is missing and re-checks. Typed Permission.* constants, no string typos.

Read the guide →
02

Read, write, update

All 42 record types with a readSteps-style helper each, plus generic readRecords with paging.

Read the guide →
03

Aggregates

aggregateRecord, Instant buckets by duration, calendar buckets by period.

Read the guide →
04

Changelog sync

getChangesToken → pullChanges drains upserts and deletes for incremental sync.

Read the guide →
05

Resume polling

useForegroundPoll re-reads on every foreground until the data arrives, without fake zeros.

Read the guide →
06 1.2.0-alpha

Matchmaking & PHR

Feature-gated Matchmaking, planned exercise, and FHIR medical records behind getFeatureStatus.

Read the guide →
The resume problem

Health Connect has no push. Your first read is often 0.

Samsung Health, Fitbit, and Google Fit sync in the background. When your app comes to the foreground, the first read usually returns before they finish. The polling helpers keep trying until ready passes, then report whether the result is real.

  • Polls on mount and on every AppState resume
  • satisfied: false means the timeout hit, so it may be a real zero
  • Non-React: pollOnForeground, pollUntil, waitUntil
TodaySteps.tsx
import {
  readSteps,
  timeRangeToday,
  useForegroundPoll,
} from '@solutionforest/android-health-connect';

export function TodaySteps() {
  const { value, satisfied, loading } = useForegroundPoll(
    () => readSteps({ timeRangeFilter: timeRangeToday() }),
    {
      ready: (r) => r.records.length > 0,
      timeoutMs: 15_000,
    },
  );
  // satisfied === false → timed out; may be a real 0
}
Install

Two registries, one package name.

Every release goes to npmjs.org with provenance and is mirrored to GitHub Packages. Pick whichever your org already uses.

npmjs.org primary

No setup needed

Published by GitHub Actions through OIDC Trusted Publishing.

terminal
yarn add @solutionforest/android-health-connect
npm.pkg.github.com mirror

GitHub Packages

Scope the registry, then use a classic PAT with read:packages.

.npmrc
@solutionforest:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT
For AI agents

Teach your coding agent this library.

The package ships skills.md, an agent skill with the version lines, hard constraints, and the right call order. Install it in your app repo and Cursor, Claude Code, or Codex will follow it instead of guessing APIs.

01 · from the package recommended

Copy the skill that matches your install

Run in your app root after installing the package. Commit the folder so the whole team gets it.

terminal
mkdir -p .cursor/skills/android-health-connect
cp node_modules/@solutionforest/android-health-connect/skills.md \
  .cursor/skills/android-health-connect/SKILL.md
Cursor.cursor/skills/android-health-connect/SKILL.md
Claude Code.claude/skills/android-health-connect/SKILL.md
Codex, others.agents/skills/android-health-connect/SKILL.md
02 · ask your agent

Or paste this prompt

Works before the package is installed. The agent downloads the latest skill from this site.

Install the android-health-connect agent skill: download https://solutionforest.github.io/AndroidHealthConnect/skills.md and save it as SKILL.md in this project's skills folder (.cursor/skills/android-health-connect/ for Cursor, .claude/skills/android-health-connect/ for Claude Code, otherwise .agents/skills/android-health-connect/). Then follow it whenever you work with @solutionforest/android-health-connect.

or with curl
curl -fsSL --create-dirs \
  -o .cursor/skills/android-health-connect/SKILL.md \
  https://solutionforest.github.io/AndroidHealthConnect/skills.md

Read skills.md →

Ship health features this week.

Availability, permissions, first read, and resume polling in four steps.