Multi-platform JS-Native bridge

One protocol.
Four platforms.

One message protocol, one session model, and one set of WebAssets — running on Android, iOS, Flutter and HarmonyOS. Not a shared runtime: a shared contract.

Android· iOS· Flutter· HarmonyOS

The problem

Fragmented native channels

Android WebMessagePort, iOS WKScriptMessageHandler, Flutter JS channels, HarmonyOS ArkWeb — every platform speaks a different dialect of JS-Native messaging.

No session or handshake

Ad-hoc bridges lack a handshake, session lifecycle and cancellation semantics — every H5 page reinvents its own transport.

Security logic scattered

Origin checks, method whitelists and session validation end up duplicated and inconsistent across platforms and pages.

Four implementations, four behaviors

Without a common contract, each platform re-implements the bridge — and each drifted implementation raises integration costs.

The JsBridge2 answer

01

Protocol v1

A single message envelope — request / response / event — with handshake, session, timeout and scope cancellation defined once, in the spec.

02

Security policy chain

A fixed evaluation order: shape → handshake gate → origin → method gate → session → host policies. Hosts extend, never override.

03

Shared WebAssets

One jsbridge-sdk.js bundle runs identically in all four native shells. One source of truth, synced to every platform.

The goal is cross-platform protocol consistency — not a shared runtime.

Three layered tiers

Tier 3 — extensions lifecycle · registry · system adapters
Tier 2 — JsBridge session · policies · handshake
Tier 1 — CoreBridge pure protocol dispatch · handlers · transport
api BridgeMessage · BridgeError · contracts

Unidirectional dependencies: JsBridge → CoreBridge → api. CoreBridge has zero security dependencies; security has zero core dependencies.

Four platforms, one contract

Quick start

Build the JS SDK and sync it to all four platforms first git clone https://github.com/xesam/JsBridge2.git cd JsBridge2 cd web-assets && pnpm install && pnpm sync && cd ..
Then load the SDK from any WebView page <script src="./jsbridge-sdk.js"></script> const client = createJsBridgeClient({ origin, pageInstanceId })

Documentation