ribaunt/widget-react that gives you typed props, callback props for every widget event, and an imperative ref handle — no manual DOM event wiring needed. The wrapper also handles dynamic importing internally, so you never need to worry about SSR guard boilerplate even when using it in a Next.js App Router component.
The widget relies on the Web Crypto API and therefore requires a secure context. Use
https:// in production and http://localhost during local development. Plain local-network HTTP URLs may fail in some browsers.Using the React wrapper (recommended)
ImportRibauntWidget from ribaunt/widget-react and place it anywhere in your JSX. Every configuration option is available as a typed prop, and each widget event maps to an on* callback.
If you are using the Next.js App Router, add
'use client' at the top of the file — see the Next.js integration guide for details.Imperative handle (ref)
Pass aref typed as RibauntWidgetHandle to call reset(), getState(), or startVerification() from your own code — for example, to trigger verification from a custom button or to reset after a failed form submission.
| Method | Description |
|---|---|
startVerification() | Programmatically starts the proof-of-work solve. |
reset() | Returns the widget to its initial state. |
getState() | Returns the current widget state string, or '' if the widget is not yet mounted. |
Live prop updates
The React wrapper syncs the following props to the underlying web component after mount — you do not need to remount the widget (e.g. by changing
key) when any of these values change:challengeEndpointverifyEndpointautoVerifyshowWarningwarningMessagesolveTimeoutdisabled
key whenever one of these props changed, you can safely remove that workaround.Using the raw web component
For advanced cases where you want full control over DOM event listeners, you can register the web component yourself with a side-effect import and use<ribaunt-widget> directly in JSX. Ribaunt ships TypeScript declarations for both HTMLElementTagNameMap and JSX.IntrinsicElements, so you get type safety either way.
When using the raw web component approach in a server-rendered environment you must guard the import yourself (e.g. inside a
useEffect) to prevent it from running during SSR. The ribaunt/widget-react wrapper handles this automatically, which is why it is the recommended approach.