Connect.js exposes four callbacks. Each callback marks a different point in the widget lifecycle.
Callback summary
onSuccess
Account linking returns an object containing a short-lived code.
A payment flow returns charge data instead. Keep flow-specific handlers separate so the code does not assume one response shape for both.
onClose
close() invokes this callback, including when the SDK closes after success.
onLoad
Use onLoad to enable the trigger only after the widget is ready.
onEvent
The current SDK maps widget messages to these event names:
Payload handling
Payload fields depend on the event and may include an institution, authentication method, error metadata, page name, selected-account count, timestamp, or the optional reference supplied during setup.
Read event data defensively:
Do not record credentials, MFA values, BVNs, account numbers, or unreviewed full event payloads. Define an allowlist of fields for analytics and logs.
Success semantics
ACCOUNT_LINKED is useful telemetry about widget progress. Use onSuccess to obtain the auth code and start the backend exchange. Treat the backend’s successful exchange and persistence as application-level completion.