Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/kingstinct/react-native-healthkit/llms.txt

Use this file to discover all available pages before exploring further.

React Native HealthKit provides a comprehensive, type-safe API for accessing Apple HealthKit data in your React Native applications.

Import patterns

The library exports all functions and types from a single entry point:
import {
  // Core functions
  requestAuthorization,
  isHealthDataAvailable,
  
  // Query functions
  queryQuantitySamples,
  queryCategorySamples,
  queryWorkoutSamples,
  
  // Save functions
  saveQuantitySample,
  saveCategorySample,
  saveWorkoutSample,
  
  // React Hooks
  useHealthkitAuthorization,
  useMostRecentQuantitySample,
  useSubscribeToChanges,
  
  // Types
  QuantityTypeIdentifier,
  CategoryTypeIdentifier,
  AuthorizationStatus,
} from '@kingstinct/react-native-healthkit';

Module organization

The library is organized into several logical modules:

Core

Authorization, availability, and background delivery

Quantity Types

100+ numerical health metrics (steps, heart rate, etc.)

Category Types

63 categorical health data types (sleep, symptoms, etc.)

Workouts

75+ workout activity types with routes and statistics

Correlations

Related samples (blood pressure, food entries)

Characteristics

User characteristics (age, sex, blood type)

React Hooks

Declarative data fetching with React Hooks

Types

TypeScript interfaces and type definitions

Programming patterns

Imperative API

All functions return Promises for async operations:
const { samples } = await queryQuantitySamples(
  'HKQuantityTypeIdentifierStepCount',
  {
    from: new Date(2024, 0, 1),
    to: new Date(),
  }
);

Declarative API (React Hooks)

Hooks automatically manage subscriptions and state:
const mostRecentSteps = useMostRecentQuantitySample(
  'HKQuantityTypeIdentifierStepCount'
);

Type safety

The library provides comprehensive TypeScript support with:
  • Strict type checking for all identifiers and parameters
  • Inference of return types based on query type
  • Autocomplete for all HealthKit constants and enums
  • Compile-time validation of units and data types
// TypeScript knows this returns a QuantitySample with specific fields
const sample = await getMostRecentQuantitySample(
  'HKQuantityTypeIdentifierHeartRate'
);

// ✅ Valid - TypeScript allows these fields
console.log(sample.quantity, sample.unit);

// ❌ Error - TypeScript catches invalid fields
console.log(sample.invalidField);

Platform support

React Native HealthKit is iOS-only. The library will log warnings and return default values on Android and other platforms.
The library automatically handles platform detection:
const isAvailable = isHealthDataAvailable();

if (isAvailable) {
  // Safe to use HealthKit APIs
}

Performance

React Native HealthKit is built on react-native-nitro-modules for optimal performance:
  • Zero-copy data transfer between native and JavaScript
  • Type-safe native bindings without serialization overhead
  • Direct memory access for large datasets
  • Lazy evaluation for complex queries

Next steps

Authorization

Request permissions to access health data

Query data

Learn how to query and read health data

Build docs developers (and LLMs) love