GuidesComponents

Polyfills and runtime setup

Initialize runtime APIs required by the Ovok client

  • Stable unknown
  • Release candidate since 1.16.1-rc.3
  • Development since 1.16.1-dev.2111+9796905

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 native runtime
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 the Ovok client. Do not call it during render or once per screen. Use cleanupOvokNativeRuntime only when a test or controlled runtime teardown needs to remove the globals.

Storage and credentials

The Ovok client from @ovok/native/next keeps its session in the secureStore you pass it, such as expo-secure-store; ExpoClientStorage is not needed for it. 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.

Last updated on

On this page