# The next client (preview)

Canonical page: https://docs.ovok.com/native-sdk/guide/modules/next

`@ovok/native/next` is the React Native edition of `@ovok/core/next`. It exports the same client API, keeps sessions in the device's secure store and supplies the `crypto.getRandomValues` that Hermes lacks. The native auth, CMS, questionnaire, image, socket, and health-sync modules use this client through `OvokProvider` from `@ovok/core/next/react`.

The Flutter SDK follows this contract, so its names match.

## Create a client [#create-a-client]

```ts
import * as Crypto from 'expo-crypto';
import * as SecureStore from 'expo-secure-store';
import { Ovok } from '@ovok/native/next';

export const ovok = new Ovok({
  baseUrl: 'https://api.sandbox.ovok.com',
  tenantCode: 'your-tenant',
  secureStore: SecureStore,
  getRandomValues: Crypto.getRandomValues,
});
```

Mount one provider above the native modules:

```tsx
import { OvokProvider } from '@ovok/core/next/react';

<OvokProvider client={ovok}>
  <App />
</OvokProvider>;
```

Health import reads the signed-in Patient from this session. It stores each provider cursor under the current tenant, project, and patient. A background Health Connect task must restore the same native client session and pass the matching `patientId` to `runAndroidHealthConnectSync`; the task refuses to import for another patient.

| Option | Required | Notes |
|---|---|---|
| `baseUrl`, `tenantCode` | Yes | See the [JavaScript SDK's next-client guide](https://docs.ovok.com/web-sdk/core/next-client). |
| `secureStore` | Yes | `expo-secure-store`, or anything with `getItemAsync`, `setItemAsync` and `deleteItemAsync`. |
| `secureStoreOptions` | No | Passed to every SecureStore call, such as `{ keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK }` for background launches. |
| `getRandomValues` | No | Used only when the runtime has no `crypto.getRandomValues`. Sign-in needs one. |
| `fhirPath`, `clientId`, `fetch`, `timeoutMs`, `maxNetworkRetries`, `onUnauthenticated` | No | See the [JavaScript SDK's next-client guide](https://docs.ovok.com/web-sdk/core/next-client). |

There is no `clientSecret`: anything shipped inside an app can be extracted from it.

## Secure storage [#secure-storage]

- **Chunking:** SecureStore warns past 2048 bytes per value, so each value is split across numbered entries.
- **Keys:** characters SecureStore rejects in a key, such as `:`, are written as `_`.
- **Locked keychain:** a read rejected before first unlock counts as "no session". The client never deletes anything because a read failed.

## Bluetooth [#bluetooth]

Scanning, pairing, connecting and saving readings through this client are in [Bluetooth on the next client](/native-sdk/guide/modules/next-bluetooth).

## Health data [#health-data]

Import HealthKit and Health Connect data through the [`@ovok/native/next/data-sync` API](/native-sdk/guide/modules/next-data-sync).
For Android headless imports and background-safe storage, see [background sync on the next client](/native-sdk/guide/modules/next-background-sync).

The next client also persists measurement writes that cannot finish immediately.
Retry them after connectivity returns with `await ovok.measurements.offlineQueue.flush()`.

## Everything else [#everything-else]

Sign-in, FHIR, paging and errors work as in the [JavaScript SDK's next client](https://docs.ovok.com/web-sdk/core/next-client).

## UI and content modules [#ui-and-content-modules]

These Next subpaths re-export the existing module APIs. Their previous import paths
remain available.

| Module | Next import | API reference |
| --- | --- | --- |
| UI | `@ovok/native/next/ui` | [UI](/native-sdk/reference/ui) |
| Theme | `@ovok/native/next/theme` | [Theme](/native-sdk/reference/theme) |
| Tile | `@ovok/native/next/tile` | [Tile](/native-sdk/reference/tile) |
| Picker sheet | `@ovok/native/next/picker-sheet` | [Picker sheet](/native-sdk/reference/picker-sheet) |
| Progress ring | `@ovok/native/next/progress-ring` | [Progress ring](/native-sdk/reference/progress-ring) |
| Progress bar | `@ovok/native/next/progress-bar` | [Progress bar](/native-sdk/reference/progress-bar) |
| Breathing exercise | `@ovok/native/next/breathing-exercise` | [Breathing exercise](/native-sdk/reference/breathing-exercise) |
| Journal | `@ovok/native/next/journal` | [Journal](/native-sdk/reference/journal) |
| Diary | `@ovok/native/next/diary` | [Diary](/native-sdk/reference/diary) |
| Observation detail | `@ovok/native/next/observation-detail` | [Observation detail](/native-sdk/reference/observation-detail) |
| PDF | `@ovok/native/next/pdf` | [PDF](/native-sdk/reference/pdf) |
| Image | `@ovok/native/next/image` | [Image](/native-sdk/reference/image) |
| Tab | `@ovok/native/next/tab` | [Tab](/native-sdk/reference/tab) |
| Setting | `@ovok/native/next/setting` | [Setting](/native-sdk/reference/setting) |
| Language switcher | `@ovok/native/next/language-switcher` | [Language switcher](/native-sdk/reference/language-switcher) |
| CMS | `@ovok/native/next/cms` | [CMS](/native-sdk/reference/cms) |
| Content | `@ovok/native/next/content` | [Content](/native-sdk/reference/content) |
| Measurement | `@ovok/native/next/measurement` | [Measurement](/native-sdk/reference/measurement) |
| Patient | `@ovok/native/next/patient` | [Patient](/native-sdk/reference/patient) |

## API reference [#api-reference]

Every export of `@ovok/native/next`, with signatures, props and types, is in the [`next` API reference](/native-sdk/reference/next).
