Polyfills and runtime setup
Runtime setup has a dedicated @ovok/native/polyfills subpath so it can run before
the app imports the rest of the SDK. polyfillOvokWebAPIs is the preferred
initializer for new code.
// index.js: initialize before Expo Router loads the app bundle.
const { polyfillOvokWebAPIs } = require("@ovok/native/polyfills");
polyfillOvokWebAPIs();
require("expo-router/entry");
Set the app's package.json main field to index.js so this file runs before
Expo Router imports the app. Keep this entry file in CommonJS form; a static import
of the app or expo-router/entry can evaluate SDK modules before the initializer.
Public exports
| Export | Purpose |
|---|---|
polyfillOvokWebAPIs | Installs the web APIs required by the Ovok mobile client |
cleanupOvokNativeRuntime | Removes the installed polyfills for tests or controlled teardown |
ExpoClientStorage | Client storage implementation backed by Expo storage primitives |
ExtendedExpoCrypto | Expo-compatible crypto implementation |
IExpoClientStorage | Storage adapter type |
PolyfillEnabledConfig | Optional polyfill configuration type |
initWebSocketManager | Initializes the WebSocket manager used by the client runtime |
Call polyfillOvokWebAPIs once from the application entry point, before importing
the app module, creating, or using OvokClient. Do not call it during render or
once per screen. Legacy initializer aliases remain available for compatibility;
use polyfillOvokWebAPIs for new code. Use cleanupOvokNativeRuntime only when a
test or controlled runtime teardown needs to remove the globals.
Storage and credentials
ExpoClientStorage provides the client storage boundary; it does not decide which
account or patient is active. For credentials needed after an Android background
relaunch, use the dedicated adapter from
@ovok/native/background-sync.
Public import boundary
Import runtime setup from @ovok/native/polyfills; this subpath loads the polyfill
module without evaluating the package root and its other SDK modules. Import the app
and other native features only after the setup call.