@capgo/capacitor-health
Overview
Section titled “Overview”@capgo/capacitor-health reads and writes user health data through Apple HealthKit on iOS and Health Connect on Android. Use it for step counts, workouts, sleep stages, vitals, and nutrition style samples without maintaining two separate native SDK integrations in your app layer.
Fitness dashboards, habit apps, clinical adjacent wellness products, and corporate wellness programs commonly start with requestAuthorization, then readSamples or saveSample for the metrics they care about.
Platform support
Section titled “Platform support”| Platform | Support | Notes |
|---|---|---|
| iOS | Yes | HealthKit authorization and samples |
| Android | Yes | Health Connect, optional history permission for reads beyond about 30 days |
| Web | Limited | isAvailable reports unsupported native SDKs |
Android only helpers: openHealthConnectSettings, showPrivacyPolicy.
Core Capabilities
Section titled “Core Capabilities”isAvailable- Returns whether the current platform supports the native health SDK.requestAuthorization- Requests read/write access to the provided data types.checkAuthorization- Checks authorization status for the provided data types without prompting the user.readSamples- Reads samples for the given data type within the specified time frame.
Public API
Section titled “Public API”| Method | Description |
|---|---|
isAvailable | Returns whether the current platform supports the native health SDK. |
requestAuthorization | Requests read/write access to the provided data types. |
checkAuthorization | Checks authorization status for the provided data types without prompting the user. |
readSamples | Reads samples for the given data type within the specified time frame. |
saveSample | Writes a single sample to the native health store. |
getPluginVersion | Get the native Capacitor plugin version. |
openHealthConnectSettings | Opens the Health Connect settings screen (Android only). On iOS, this method does nothing. |
showPrivacyPolicy | Shows the app’s privacy policy for Health Connect (Android only). On iOS, this method does nothing. |
queryWorkouts | Queries workout sessions from the native health store. Supported on iOS (HealthKit) and Android (Health Connect). |
queryAggregated | Queries aggregated health data from the native health store. Aggregates data into time buckets (hour, day, week, month) with operations like sum, average, min, or max. This is more efficient than fetching individual samples for large date ranges. |
Source Of Truth
Section titled “Source Of Truth”This reference is synced from src/definitions.ts in capacitor-health.
Keep going from @capgo/capacitor-health
Section titled “Keep going from @capgo/capacitor-health”If you are using @capgo/capacitor-health to plan native plugin work, connect it with Using @capgo/capacitor-health for the native capability in Using @capgo/capacitor-health, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins, and Ionic Enterprise Plugin Alternatives for the product workflow in Ionic Enterprise Plugin Alternatives.