Skip to main content
A minimal integration that loads a web-based identity journey inside a React app. This example is the smallest possible working bridge integration β€” a BridgeHostProvider, an <iframe>, and one capability handler.

What this example demonstrates

  • Instantiating BridgeHostProvider with origin allowlist and capabilities
  • Declaring document-capture support via the capabilities prop
  • Registering a handler with useBridgeCapability
  • Surfacing internal bridge errors via useBridgeHostError

Complete source

How it works

  1. BridgeHostProvider wraps the iframe-rendering subtree. The provider waits for iframe to transition from null to a real element, then instantiates the underlying BridgeHost and snapshots allowedOrigins, hostVersion, and capabilities.
  2. useState for the iframe element is required β€” not useRef. The provider’s effect depends on iframe, and refs don’t trigger re-renders when the iframe element mounts.
  3. navigator.permissions.query reads the current camera permission state. Passing it through CapabilityInfo.permissionState lets the journey decide whether to surface a permission prompt before triggering capture.
  4. useBridgeCapability registers a handler for the "camera.document.capture" action. On mount it calls host.registerHandler; on unmount it deregisters (only if its own proxy is still the active handler).
  5. useBridgeHostError subscribes to internal SDK errors (handler exceptions, send failures, delegate throws). Lifted into local state so the banner re-renders when an error occurs.

What happens at runtime

Required page configuration

For this minimal example, no special configuration beyond a normal React app is needed. In production, ensure your host page sets:
  • Content-Security-Policy: frame-src https://journey.example.com; β€” Allow the journey origin in your CSP.
  • <iframe allow="camera"> β€” Delegate camera permission to the iframe context.
  • HTTPS in production β€” Mixed content (HTTPS host + HTTP iframe) is silently blocked by browsers.

Next steps

  • Two-Way Communication β€” Send events to the journey and observe inbound traffic.
  • Advanced Integration β€” Production patterns with pre-launch validation, lifecycle, and error states.
  • Tutorial β€” Build the full app with backend token exchange.