callbacks prop:
Available callbacks
- onFormChange — the swap form values changed (asset, amount, destination network, …).
- onSwapCreate — a new swap was successfully created after submitting the form.
- onSwapComplete — a swap completed successfully.
- onSwapStatusChange — a swap’s status changed (pending, completed, failed, …).
- onSwapModalStateChange — the swap modal opened or closed.
- onBackClick — the user clicked the back button in the swap flow.
- onMenuNavigationChange — the user navigated inside the widget menu.
- onError — a runtime error occurred inside the widget.
Notes
- Keep the
callbacksobject referentially stable — hoist it to module scope or memoize it, otherwise the widget re-initializes its callback wiring on every render. - A throwing callback can’t break the widget — every callback invocation is wrapped in try/catch inside the widget.
- Payloads are typed as
unknownin the public package (WidgetCallbacks), so cast to the payload shapes documented on each event page. callbacks.onErrorreports errors inside a running widget. Failures to load the widget surface through the top-levelonErrorprop instead — see Widget delivery and security.