javascript
Adding the async attribute can cause the inline code to return undefined because the library may not be available at that moment. So avoid the use of async and defer for now.
javascript
| Parameter | Type | Description |
|---|---|---|
| type | string | Widget Type: Values are ‘custom’, ‘verification’, ‘identification’, ‘verification’, ‘liveness’ |
| app_id | string | Application Id, Get it from your dojah application dashboard here |
| p_key | string | Public Key, Get it from your dojah application dashboard here |
| reference_id | string | Reference ID, It can be passed to keep track of the verification steps (Started, Ongoing, Successful). NB: reference_id character length must be greater than 10 |
| widget_id | string | Widget ID, Get it from your Easy Onboard application dashboard here |
| user_data | object | Automatically update the user data page, and thus skip the page |
| gov_data | object | Automatically update the government data page, and thus skip the page |
| metadata | object | Your application’s metadata to be passed back to you via webhook, onSuccess, or onError |
| onSuccess | function | Called when the user has completed all verification steps in the widget flow. The sample response data below is returned to this callback. |
| onError | function | Called when an error occurs before all verification steps are completed, preventing the user from finishing the flow. |
| embed | boolean | When set to true, renders the widget inline inside a specified DOM element instead of opening it as a modal overlay. Defaults to false. |
| container | string | A CSS selector pointing to the DOM element that will host the embedded widget. Required when embed is true. |
| onClose | function | Called when the user terminates the widget via the close button before completing all steps. |
Embedding the Widget Inline
By default, the Dojah widget opens as a modal overlay on top of your page. If you prefer to render it inline within your existing page layout, use the When to use embedded mode:
embed and container options together.embed (boolean, optional) — Set this to true to switch the widget from modal mode to embedded mode. When embedded, the widget renders directly inside a DOM element on your page instead of appearing as a floating overlay. This is useful when you want the verification flow to feel like a native part of your application rather than a popup.container (string, optional) — A CSS selector that identifies the HTML element the widget should render inside. This is required when embed is set to true. The selector follows standard CSS syntax (e.g. "#embed-container" for an element with id="embed-container", or ".verify-section" for a class-based selector).Example usage:- You want the widget to appear as part of your page flow (e.g. inside a settings panel, onboarding stepper, or dashboard section).
- You need full control over the widget’s positioning, sizing, and surrounding layout.
- You want to avoid the modal overlay blocking other page content.
connect.setup(). The element should have explicit dimensions (width/height) so the widget renders correctly within the allocated space.onSuccess — All verification steps completed
onSuccess — All verification steps completed
The
onSuccess callback is triggered when the user has completed all the verification steps configured in the widget flow. This confirms that every step — such as document capture, liveness check, government data entry, etc. — has been submitted by the user.Important: onSuccess confirms flow completion, not that the user passed all checks. A user may complete every step but still fail backend validation (e.g., document mismatch, failed liveness). Always verify the final result from your backend using the reference ID.onError — Error before all steps are completed
onError — Error before all steps are completed
The
onError callback is triggered when an error occurs before all verification steps are completed. This prevents the user from finishing the flow. Common causes include:- Network connectivity issues
- SDK initialization or configuration errors
- Provider-side failures during a verification step
- Unexpected interruptions during the flow
onError fires, the verification is incomplete. Your application should handle this gracefully — for example, by prompting the user to retry.onClose — Widget terminated via close button
onClose — Widget terminated via close button
Recommended ImplementationAfter the widget interaction, create a backend flow or confirmation page that retrieves the actual verification result using the reference ID generated during the verification process. You can retrieve the final verification details through:
- Webhook notifications — Subscribe to services
- Verification Details API — Get verification details
| Status | Description |
|---|---|
| Ongoing | The verification process is currently in progress. |
| Completed | The verification has been successfully completed and passed all checks. |
| Pending | The verification is awaiting further action or review. |
| Failed | The verification was completed but did not pass one or more verification checks. |
| Abandoned | The verification was started but not completed by the user. |
Typescript implementation
If you want to use typescript on some classes that are not available now or in the future, you could look at extending the global ‘window’ interface. You can follow below steps to guide you: With typescript, you need to extend the global Window interface with additional properties. Create a new folder “types” Add a file “index.d.ts” Put below code inside your “index.d.ts” filetypescript
typescript
onSuccess callback is invoked with the verification response data. If an error occurs before all steps are completed, onError is called instead. If the user closes the widget via the close button, onClose is triggered.
Use the overall status (response.status (Boolean, i.e true or false)) to ascertain if the request failed or succeeded.
Webhook NotificationsYou can receive the same data below (also passed to onSuccess and onError) via a webhook call.Register your url for webhook calls here and ensure
kyc.widget is the service you are subscribed to.In Config object Kindly set webhook object value to true (Boolean)Example : webhook : trueResponse