# JS-engine bridge

Canonical page: https://docs.ovok.com/flutter-sdk/js-bridge

`OvokJsBridge` runs the `@ovok/native/next` contract in an embedded JavaScript engine, so Flutter calls the same code as the Native SDK instead of a Dart copy. HTTP and the secure store stay in Dart; Bluetooth, health import and background sync never enter the engine.

## Route a call through the engine [#route-a-call-through-the-engine]

Give the bridge and the client the same secure store, so both read one session, then pass the bridge to `Ovok`:

```dart
final bridge = OvokJsBridge(baseUrl: baseUrl, tenantCode: 'acme', secureStore: store);
final ovok = Ovok(
  baseUrl: baseUrl,
  tenantCode: 'acme',
  secureStore: store,
  jsContract: bridge,
);
final patient = await ovok.fhir.read('Patient', 'p1');
```

Today only `fhir.read` uses the bridge, and only when called without `RequestOptions`. A failure inside the engine throws an `OvokJsException` with the JavaScript error name, message and stack. See the [OvokJsBridge reference](/flutter-sdk/reference/ovok_flutter/ovok-js-bridge).
