Skip to main content

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​

ExportPurpose
polyfillOvokWebAPIsInstalls the web APIs required by the Ovok mobile client
cleanupOvokNativeRuntimeRemoves the installed polyfills for tests or controlled teardown
ExpoClientStorageClient storage implementation backed by Expo storage primitives
ExtendedExpoCryptoExpo-compatible crypto implementation
IExpoClientStorageStorage adapter type
PolyfillEnabledConfigOptional polyfill configuration type
initWebSocketManagerInitializes 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.