Configure the client

Configure the Ovok API origin, tenant, storage, and request behavior.

  • Stable unknown
  • Release candidate since 0.4.49-rc.2
  • Development since 0.4.49-dev.493+062a3db

Create Ovok from the package root and pass the API origin and tenant code:

import { Ovok } from '@ovok/core';

const ovok = new Ovok({
  baseUrl: 'https://api.sandbox.ovok.com',
  tenantCode: 'your-tenant',
  fhirPath: 'fhir/R4',
});

baseUrl must be an absolute HTTP(S) URL. tenantCode is required. fhirPath defaults to fhir; leading and trailing slashes are removed before requests.

Storage and requests

  • Session storage: the session lives in memory by default. Pass any OvokStorage (localStorage, AsyncStorage, or your own getItem/setItem/removeItem) to keep users signed in across restarts.
  • Requests: timeoutMs and maxNetworkRetries tune every request; fetch replaces the runtime fetch.
  • Sign-out notice: onUnauthenticated runs when a refresh token is refused and the user has been signed out.
  • Outbox: outboxStore keeps unsent measurements (memory by default; IndexedDbOutboxStore in a browser), connectivity and lifecycle tell it when to send, outboxRequestBudget caps its requests per 30 seconds (40 by default) and logger receives its structured log entries. See ovok.outbox.

Every option, its type and its default is listed in the Ovok client reference. Keep persisted session data protected as your app's security requirements demand.

Machine credentials

Server applications may supply both clientId and clientSecret for machine authentication. Never put clientSecret in browser or mobile application code; the client rejects it when running in a browser.

A server that only reads published CMS content can pass cmsApiKey instead: a read-only key sent as x-api-key on ovok.cms reads, with no session. It is a secret too, and rejected in a browser the same way. See ovok.cms.

Use a resource namespace

The client groups operations by API domain. For example, FHIR searches use ovok.fhir:

const patients = await ovok.fhir.search('Patient', { _count: 10 });

See also

Last updated on

On this page