Skip to main content
Complete guide for using @gbgplc-internal/ggo-native-bridge-react in React applications.

Setup

Wrap your app (or the relevant subtree) with <BridgeProvider>:
The provider creates the NativeBridge singleton, auto-detects the host environment, discovers capabilities on mount, and makes the bridge available to all child components via context.

useBridge() — Access the bridge

useBridge() is the main hook for reading bridge state and reaching the underlying NativeBridge instance. It returns the environment, capability map, and helpers for capability checks:
Throws an Error if used outside a <BridgeProvider>.

Waiting for capabilities

useCapability(id) — Check a capability

Reactively check whether a specific capability is supported:

useNativeCamera(type) — Camera capture

useNativeCamera() is a convenience hook that wraps the most common bridge request — a document or selfie capture — with the right capability check, action string, and timeout. It returns a flag for whether a native capture is available and a requestCapture() function you call when the user triggers capture:

Camera type mapping

Each type value maps to a specific bridge capability and capture action: useNativeCamera works even without a <BridgeProvider>, returning isNativeAvailable: false. This makes it safe to use in components that may or may not have bridge access.

useBridgeEvent(action, callback) — Listen for host events

Key behaviours:
  • Subscribes on mount, unsubscribes on unmount
  • You do not need to wrap the callback in useCallback — the hook uses a ref internally
  • Resubscribes only if the action string changes

Emitting events

Combining hooks

Testing

Use the environment and channel options to mock the bridge in tests: