# DataSync

Canonical page: https://docs.ovok.com/native-sdk/guide/components/data-sync

`@ovok/native/data-sync` contains the native health authorization and import
components for iOS HealthKit and Android Health Connect. The platform provider
requests permissions; the matching sync component reads records and writes mapped
observations through the active OVOK client.

Start with the [HealthKit and Health Connect guide](/native-sdk/guide/modules/data-sync) for
native setup, data mapping, and an end-to-end flow. Use this page to find the
component and type references.

## Import the module [#import-the-module]

~~~tsx
import { DataSync, SyncProgressList } from "@ovok/native/data-sync";
~~~

The subpath keeps platform health libraries out of apps that do not use health
imports. Mount the app under `OvokProvider` and render sync components only when
the client and patient profile are ready.

## Components [#components]

| Component | Purpose |
| --- | --- |
| [`DataSync`](/native-sdk/guide/components/data-sync/data-sync/) | Compound API that exposes the platform providers, sync components, and manual request sheet as static members. |
| [`AppleHealthAuthorizationProvider`](/native-sdk/guide/components/data-sync/apple/health-authorization-provider/) | Requests HealthKit access and reports request state. |
| [`AppleHealthSync`](/native-sdk/guide/components/data-sync/apple/health-sync/) | Imports mapped samples from HealthKit. |
| [`AndroidHealthConnectAuthorizationProvider`](/native-sdk/guide/components/data-sync/android/health-connect-authorization-provider/) | Initializes Health Connect, requests permissions, and refreshes state when the app becomes active. |
| [`AndroidHealthSync`](/native-sdk/guide/components/data-sync/android/health-sync/) | Imports mapped records from Health Connect. |
| [`SyncProgressList`](/native-sdk/guide/components/data-sync/sync-progress-list/) | Renders per-type status, counts, and progress bars. |
| [`ManuallyRequestSheet`](/native-sdk/guide/components/data-sync/manually-request-sheet/) | Compound bottom-sheet UI for an app-owned permission prompt, with six documented subcomponents. |

For an adapter-driven permission card, see [`HealthImportCard`](/native-sdk/guide/components/ui/health-import-card).
It does not invoke the DataSync provider import pipeline.

## Exported types [#exported-types]

The module also exports:

- `AppleHealthSyncProps` and `AndroidHealthSyncProps`;
- `AppleHealthAuthorizationStatus` and `AndroidHealthConnectAuthorizationStatus`;
- `HealthSyncKey`, `HealthSyncKeys`, `HealthDataType`, and `HealthDataMode`;
- `SyncProgress` and `SyncPauseReason`;
- `SyncProgressListProps`.

Use the platform-specific props type when declaring a reusable mapping:

~~~ts
import type { AppleHealthSyncProps } from "@ovok/native/data-sync";

const dataToSync: AppleHealthSyncProps["dataToSync"] = {
  // Add only the measurement keys and HealthKit identifiers the feature needs.
};
~~~

## Runtime behavior [#runtime-behavior]

- Imports start when the platform sync component mounts.
- Both platform providers default to requesting access automatically. Pass a manual
  request renderer and `skipRequest={false}` when the app owns the prompt.
- Each sync uses `dataToSync` to map source identifiers to observation codes.
- The default provider read chunk is 250 records.
- Network loss pauses work. `wifiOnly` can also pause it on cellular data.
- HealthKit observer delivery and Android headless Health Connect work are configured
  separately; see [background sync](/native-sdk/guide/modules/background-sync).

## Related guides [#related-guides]

- [HealthKit and Health Connect](/native-sdk/guide/modules/data-sync)
- [Installation and native setup](/native-sdk/guide/how-to/installation)
- [Background sync](/native-sdk/guide/modules/background-sync)
