# react-native-healthier

> The healthiest way to interact with HealthKit in React Native

Latest version **0.0.6** (published 2022-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-healthier
pnpm add react-native-healthier
yarn add react-native-healthier
bun add react-native-healthier
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2022-07-05 |
| First published | 2022-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 502.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kyle Landell |
| Maintainers | kyle.landell |
| Keywords | react-native, ios |

## Links

- npm: https://www.npmjs.com/package/react-native-healthier
- Repository: https://github.com/klandell/react-native-healthier
- Homepage: https://github.com/klandell/react-native-healthier#readme
- Issues: https://github.com/klandell/react-native-healthier/issues
- npm.io page: https://npm.io/package/react-native-healthier

## Recent versions

- 0.0.6 (latest) — 2022-07-05
- 0.1.0-alpha.42 (alpha) — 2023-10-03
- 0.1.0-alpha.41 — 2023-10-03
- 0.1.0-alpha.40 — 2023-09-21
- 0.1.0-alpha.39 — 2023-01-31
- 0.1.0-alpha.38 — 2022-12-08
- 0.1.0-alpha.37 — 2022-12-08
- 0.1.0-alpha.36 — 2022-11-14
- 0.1.0-alpha.35 — 2022-11-11
- 0.1.0-alpha.34 — 2022-11-02
- 0.1.0-alpha.33 — 2022-11-01
- 0.1.0-alpha.32 — 2022-11-01
- 0.1.0-alpha.31 — 2022-11-01
- 0.1.0-alpha.30 — 2022-11-01
- 0.1.0-alpha.29 — 2022-10-12
- … 33 more at https://npm.io/package/react-native-healthier/versions

## README

# react-native-healthier

The healthiest way to interact with HealthKit in React Native.

## Warning: Don't use this yet. The API isn't totally settled yet and the code is a dumpster fire.

Healthier is different than other React Native libraries for Apple Health because Healthier provides an API that closely resembles the native HealthKit API. Ultimately Healthier allows you (when it's finished) to query any HealthKit data without the need to define new data accessor methods.

```TypeScript
import Healthier, {QuantityTypeIdentifier, Query, ignite} from 'react-native-healthier';

// Example: read HRV data from HealthKit
async function readHRVData(startDate: Date, limit?: number) {
  const isAvailable = await Healthier.isAvailable();
  if (!isAvailable) return;

  const sampleType = QuantityTypeIdentifier.HeartRateVariabilitySDNN;

  await Healthier.requestAuthorization({
    read: [sampleType],
  });

  const predicate = Query.compoundPredicate({
    type: 'And', 
    subpredicates: [
      Query.predicateForSamples({
        start: startDate
        options: ['StrictStartDate'],
      }),
      Query.predicateForObjectsWithDeviceProperty({
        key: 'Manufacturer',
        value: 'Apple Inc.',
      }),
      Query.predicateForObjectsWithDeviceProperty({
        key: 'Model',
        value: 'Watch',
      }),
      Query.predicateForObjectsWithDeviceProperty({
        key: 'HardwareVersion',
        value: ["Watch4,1", "Watch4,2", "Watch4,3", "Watch4,4"]
      }),
    ]
  });

  const query = Query.sampleQuery({
    sampleType,
    predicate,
    limit, 
    sortDescriptors: [Query.createSortDescriptor('SampleStartDate', true)],
  });

  const data = await Healthier.execute(query);
}
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

---
_Source: https://npm.io/package/react-native-healthier · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
