Skip to main content
This reference covers every public export in the TypeScript Bridge SDK β€” the core @gbgplc-internal/ggo-native-bridge package and the React bindings in @gbgplc-internal/ggo-native-bridge-react. Use it alongside the TypeScript Bridge SDK overview when you need exact type signatures, options, or return shapes.

Core package: @gbgplc-internal/ggo-native-bridge

The package is published as an ES module with no dependencies and runs in the browser only. The example import below names the public exports referenced throughout the rest of this section:

NativeBridge

The main bridge class. Singleton β€” use NativeBridge.getInstance() to obtain the instance.

NativeBridge.getInstance(options?)

Returns the singleton bridge instance. Creates it on the first call; subsequent calls return the existing instance (ignoring options).

NativeBridge.resetInstance()

Destroys the current singleton and resets to null. For testing only.

Properties

bridge.discoverCapabilities(timeoutMs?)

Queries the host for available capabilities. Default timeout: 5,000 ms. Returns empty {} in standalone mode.

bridge.hasCapability(id) / bridge.getCapability(id) / bridge.getCapabilities()

Check capabilities based on the last discoverCapabilities() result.

bridge.request(action, data, options?)

Sends a request to the host and waits for a correlated response. Default timeout: 30,000 ms. Throws: BridgeError with appropriate code on timeout, error, unsupported, or cancelled status.

bridge.emit(action, data)

Sends a fire-and-forget event to the host.

bridge.on(action, callback)

Subscribes to events from the host. Returns an unsubscribe function.

bridge.getMessageLog() / bridge.onMessageLog(callback)

Debugging tools. The log is capped at 500 messages. Only one onMessageLog callback at a time.

bridge.destroy()

Cleans up all resources. The instance is unusable after calling this.

detectEnvironment

Detection order: window undefined β†’ standalone, webkit.messageHandlers.gbgBridge β†’ ios, GBGBridge.postMessage β†’ android, window !== window.parent β†’ iframe, otherwise standalone.

BridgeError

See Error handling for all error codes and handling patterns.

CAPABILITY_IDS


Types


React package: @gbgplc-internal/ggo-native-bridge-react

Peer dependencies: react@19.x, @gbgplc-internal/ggo-native-bridge@>=0.1.0

BridgeProvider

useBridge()

Returns BridgeContextValue:

useCapability(capabilityId)

Returns { supported: boolean; ready: boolean; version?: string }.

useNativeCamera(type: 'document' | 'selfie')

Returns { isNativeAvailable: boolean; requestCapture: (data?) => Promise<ResponsePayload> }. Uses 120-second timeout and fallbackAllowed: true. Works outside <BridgeProvider> (returns isNativeAvailable: false).

useBridgeEvent(action, callback)

Subscribes to host events. Manages lifecycle automatically. Uses useRef internally so the callback doesn’t need memoization. See React hooks guide for detailed usage examples.