npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gbg/go-bridge-web-react

v0.2.1

Published

React bindings for @gbgplc-internal/ggo-bridge-web — Provider and hooks for embedding GBG GO identity verification journeys in a React app.

Readme

@gbg/go-bridge-web-react

React bindings for @gbg/go-bridge-web — a Provider and hooks for embedding GBG GO identity verification journeys in a React app via iframe.

The core package's README covers prerequisites (you need a GBG GO agreement and a configured journey), the messaging protocol, capability discovery, and the security model; this package layers React lifecycle management on top.

Installation

Requires React 19 (peerDependencies: react 19.x). On React 18 or earlier, use the framework-agnostic core package directly instead.

npm install @gbg/go-bridge-web-react @gbg/go-bridge-web

Quick start

import { useState } from 'react';
import type { CapabilityMap } from '@gbg/go-bridge-web';
import {
  BridgeHostProvider,
  useBridgeCapability,
  useBridgeHostError,
  useBridgeHostEvent,
} from '@gbg/go-bridge-web-react';

const CAPABILITIES: CapabilityMap = {
  'analytics.forward': { supported: true, version: '1.0' },
};

function JourneyEmbed({ journeyUrl }: { journeyUrl: string }) {
  const [iframe, setIframe] = useState<HTMLIFrameElement | null>(null);

  return (
    <BridgeHostProvider
      key={journeyUrl}
      iframe={iframe}
      allowedOrigins={[new URL(journeyUrl).origin]}
      hostVersion="my-app-1.0.0"
      capabilities={CAPABILITIES}
    >
      <iframe
        ref={setIframe}
        src={journeyUrl}
        title="Identity verification"
        sandbox="allow-scripts allow-same-origin allow-forms"
        allow="camera"
        style={{ width: '100%', height: 480, border: 0 }}
      />
      <JourneyListeners />
    </BridgeHostProvider>
  );
}

function JourneyListeners() {
  // Handle requests from the journey.
  useBridgeCapability('analytics.forward', {
    handle: (request, responder) => {
      const { data } = request.payload as { data: Record<string, unknown> };
      myTelemetry.track(data); // your analytics client — not part of the SDK
      responder.success({});
    },
  });

  // Observe fire-and-forget events from the journey.
  useBridgeHostEvent('journey.completed', (data) => {
    console.log('journey completed', data);
  });

  useBridgeHostError((err) => {
    console.error('bridge error', err);
  });

  return null;
}

API

<BridgeHostProvider>

Creates a BridgeHost once the iframe prop becomes non-null and detaches it automatically on unmount or iframe change — you never call detach() yourself.

| Prop | Type | Notes | | --- | --- | --- | | iframe | HTMLIFrameElement \| null | Pass null until the iframe has mounted (e.g. via a ref callback). | | allowedOrigins | string[] | Required. Exact origins the journey is served from. | | hostVersion | string? | Reported to the journey in capability discovery. | | capabilities | CapabilityMap? | What your page supports. | | delegate | BridgeHostDelegate? | Raw message/error observability hooks. |

allowedOrigins, hostVersion, and capabilities are read when the host is created (when iframe transitions to non-null, or changes to a new element) and are not applied on later renders; delegate is read live, so swapping it takes effect immediately. To apply changed configuration, remount the Provider — keying it on the config, as with key={journeyUrl} above, is the simplest way.

useBridgeHost(): BridgeHost | null

Returns the live BridgeHost, or null before the iframe mounts. Use it for imperative calls in response to something happening:

const host = useBridgeHost();
return (
  <button
    onClick={() => host?.sendEvent('host.locale.update', { locale: 'en-GB' })}
  >
    Switch locale
  </button>
);

(As the core README notes, sends are not queued — only send once the journey is running.)

useBridgeCapability(action, handler): void

Registers a request handler for the lifetime of the calling component. The hook keeps the registration stable across renders, so an inline { handle: ... } literal is fine.

Don't mount two live handlers for the same action: the newest registration replaces the older one. Unmounting the replaced component is safe (it won't remove the newer registration), but the replaced handler is never reinstated — when the newer component unmounts, the action is left with no handler at all. One component per action.

useBridgeHostEvent(action, listener): void

Subscribes to fire-and-forget events from the journey (e.g. the journey.* lifecycle actions — see BridgeActions in the core package). The subscription is renewed whenever the listener's identity changes; memoize it with useCallback if your component re-renders frequently.

useBridgeHostError(listener): void

Subscribes to bridge errors: capability-handler throws (before a response has been sent), delegate throws, and postMessage exceptions. Sends the SDK drops for other reasons (no iframe src yet, origin not allowlisted) surface as console warnings, not errors, and sends made through a stale host reference after the Provider has detached it (unmount or iframe change) are dropped silently — see the core README. Memoize the listener with useCallback.

License

MIT © GBG Group plc