Event Callbacks
The SDK provides callbacks to integrate with your application's logic.
This guide is specific to Web SDK 2.0. If you are still using 1.x, you can find documentation here. We strongly recommend upgrading - contact your Incode Representative for upgrade information.
The SDK provides callbacks to integrate with your application's logic.
The snippets below show the callback shapes you'd assign to the element (e.g.
flow.onFinish = ...) or set insideconfig. For full mounting examples (vanilla, React, Angular, Vue) see IncodeFlow Component and Framework Integration.
IncodeFlow Callbacks
onFinish
Called when the verification flow finishes. This is the primary callback you should set:
flow.onFinish = (result) => {
console.log('Action:', result?.action); // 'approved' | 'rejected' | 'none'
console.log('Status:', result?.scoreStatus); // 'OK' | 'WARN' | 'FAIL' | ...
console.log('Redirect:', result?.redirectionUrl);
if (result?.action === 'approved') {
// Proceed with your flow
}
};result may be undefined (the signature is (result?: FinishStatus) => void), so always null-check.
onError
Called when an error occurs:
flow.onError = (error, code) => {
console.error('Verification error:', error, code);
// Show error UI or redirect
};onModuleLoading / onModuleLoaded
Track lazy-loading of each module's UI chunk. These are config callbacks, not element callbacks:
flow.config = {
token: session.token,
onModuleLoading: (moduleKey) => setLoading(moduleKey),
onModuleLoaded: (moduleKey) => setLoading(null),
};onWasmWarmup
Called when ML models begin loading:
flow.config = {
token: session.token,
onWasmWarmup: (pipelines) => console.log('Loading ML models:', pipelines),
};onFlowEvent
Subscribe to curated flow milestones (flow.ready, flow.module.started, flow.module.completed, flow.completed, flow.error). For raw analytics events, use subscribeEvent from @incodetech/core/events.
flow.config = {
token: session.token,
onFlowEvent: (event) => console.log('Flow event:', event.type, event),
};Individual Module Callbacks
The standalone module elements (<incode-phone>, <incode-selfie>, <incode-id>, …) follow the same property-assignment pattern.
onFinish
phone.onFinish = () => console.log('Phone verified!');onError
selfie.onError = (error) => console.error('Selfie error:', error);Finish Status
The onFinish callback on IncodeFlow receives a FinishStatus object:
import type { FinishStatus } from '@incodetech/core/flow';
// FinishStatus shape:
// {
// redirectionUrl: string;
// action: 'approved' | 'rejected' | 'none';
// scoreStatus: 'OK' | 'WARN' | 'MANUAL_OK' | 'FAIL' | 'UNKNOWN' | 'MANUAL_FAIL';
// }FinishStatus is also re-exported from @incodetech/core/session if you prefer that grouping.
| Field | Description |
|---|---|
action | Final verification decision |
scoreStatus | Detailed status from scoring |
redirectionUrl | Configured redirect URL (if any) |
Dashboard Events
For tracking events to the Incode dashboard (module opens, screen transitions, custom events), see Dashboard Events.
See Also
- IncodeFlow Component: Full component reference
- Individual Modules: Module-specific callbacks
- Dashboard Events: Tracking events to the dashboard
Updated 1 day ago
