Skip to main content
The TypeScript Bridge SDK enables bidirectional communication between the GBG GO web journey and the native host app it runs inside. It handles environment detection, capability discovery, and request/response messaging so the web journey can use native device features like camera capture, NFC, and biometrics. The SDK works across all embedding environments β€” iOS WKWebView, Android WebView, iframe, and standalone browser β€” with automatic environment detection and progressive enhancement.

Packages

The SDK is published as two npm packages β€” the core library you can use anywhere, and a thin React wrapper if you’re using React 19+:

Installation

To install the SDK, run one of the commands below:
Both packages are ES modules and ship TypeScript declarations.

Quick start: Core library

Get a singleton bridge instance, check the environment, request a native capability, and listen for host events β€” all from plain TypeScript:

Quick start: React

Wrap your app in <BridgeProvider> and use the hooks β€” useBridge for environment and capability state, useNativeCamera for capture requests with web fallback:

Environment behaviour

In standalone mode, the bridge is fully functional but reports no capabilities. This enables progressive enhancement β€” your app works in any environment, and native features activate automatically when a host is present.

Standard capabilities

Common pitfalls

Watch out for these common integration mistakes:
  • Don’t use the bridge in SSR: it requires window and browser APIs. In Next.js, ensure bridge code only runs on the client. See the Next.js usage guide.
  • Always check capabilities before requesting: don’t assume a capability is available. Use hasCapability() or the useCapability() hook first.
  • Handle timeouts: the default request timeout is 30 seconds. Camera requests via useNativeCamera use 120 seconds.
  • Call discoverCapabilities() early: <BridgeProvider> does this automatically, but if using the core library directly, call it early in your app lifecycle.
  • The bridge is a singleton: NativeBridge.getInstance() always returns the same instance. Options are only used on the first call.

Guides

  • Configuration β€” Bridge options, timeouts, and React provider configuration
  • React hooks β€” useBridge, useCapability, useNativeCamera, useBridgeEvent
  • Error handling β€” Typed error codes, recoverability, and handling patterns
  • Security β€” Transport security, iframe origin validation, PII handling
  • Next.js usage β€” App Router and Pages Router integration
  • API reference β€” Complete reference for all public exports