Features
- Simple API - Singleton pattern with easy-to-use methods
- Flexible Integration - Use UniLink URL directly or create sessions via backend
- Responsive - Works on desktop and mobile browsers
- Customizable - Configuration options for styling and behavior
- Multiple Formats - ESM, CommonJS, and UMD builds
- TypeScript Support - Full type definitions included
- Modal & Inline Modes - Choose between modal overlay or inline embedding
- Event Callbacks - Real-time events for verification progress (started, step completed, finished)
- State Management - Observe SDK state for custom UI
Installation
NPM/Yarn
CDN (UMD)
Vanilla JavaScript
ES Modules / TypeScript
Script Tag (UMD)
Framework Examples
SDK Web Examples
React, Angular, Svelte, Next.js, Nuxt, Vue, and more — with examples and documentation for each framework.
Integration Methods
There are two ways to integrate the SDK:Method 1: UniLink URL (Simplest)
Use your workflow’s UniLink URL directly from the Didit Console. No backend required.Method 2: Backend Session (Recommended for production)
Your backend creates a session via the Didit API and returns the verification URL. This gives you more control over session creation, user tracking, and security. Read more about how the create session API works here: Create Session API referenceConfiguration
| Option | Type | Default | Description |
|---|---|---|---|
loggingEnabled | boolean | false | Enable SDK logging for debugging |
containerElement | HTMLElement | document.body | Custom container element to mount the modal |
zIndex | number | 9999 | Z-index for the modal overlay |
showCloseButton | boolean | true | Show close button on modal |
showExitConfirmation | boolean | true | Show exit confirmation dialog when closing |
closeModalOnComplete | boolean | false | Automatically close modal when verification completes |
embedded | boolean | false | Render verification inline instead of modal overlay |
embeddedContainerId | string | — | Container element ID for embedded mode (required when embedded is true) |
Embedded Mode
Render verification inline instead of a modal overlay:Verification Results
The SDK returns three types of results:Completed
Verification flow finished (approved, pending, or declined).Cancelled
User closed the verification modal.Failed
An error occurred during verification.State Management
You can observe the SDK state for custom UI:API Reference
DiditSdk.shared
The singleton SDK instance.Methods
| Method | Description |
|---|---|
startVerification(options) | Start the verification flow |
close() | Programmatically close the verification modal |
destroy() | Destroy the SDK instance and clean up |
Properties
| Property | Type | Description |
|---|---|---|
state | DiditSdkState | Current SDK state |
configuration | DiditSdkConfiguration | Current configuration |
isPresented | boolean | Whether verification modal is open |
errorMessage | string | Error message (when in error state) |
Callbacks
| Callback | Parameters | Description |
|---|---|---|
onComplete | (result: VerificationResult) | Called when verification finishes |
onStateChange | (state: DiditSdkState, error?: string) | Called on state changes |
onEvent | (event: VerificationEvent) | Called on granular verification events |
Granular Events
Track verification progress with theonEvent callback:
Event Reference
| Event | Description | Data Payload |
|---|---|---|
didit:ready | The page is ready and the sessionId is available | { sessionId } |
didit:started | User started verification | { sessionId? } |
didit:step_started | A verification step began | { step, sessionId? } |
didit:step_completed | A step finished successfully | { step, nextStep?, sessionId? } |
didit:step_changed | Current step changed | { step, previousStep?, sessionId? } |
didit:media_started | Camera/media capture started | { step, mediaType } |
didit:media_captured | Photo/video captured | { step, isAuto } |
didit:document_selected | User selected document type and country | { documentType, country } |
didit:verification_submitted | Data submitted for processing | { step, sessionId? } |
didit:code_sent | OTP code sent | { step, channel?, codeSize?, sessionId? } |
didit:code_verified | OTP code verified | { step, sessionId? } |
didit:status_updated | Session status changed | { status, previousStep?, sessionId? } |
didit:completed | Verification flow completed | { sessionId?, status?, country?, documentType? } |
didit:cancelled | User cancelled verification | { sessionId? } |
didit:error | An error occurred | { error, step?, sessionId? } |
didit:close_request | User requested to close modal | (no data) |
Step Values
Thestep field can be one of:
document_selection- Document type selectiondocument_front- Front side of documentdocument_back- Back side of documentface- Face/liveness verificationemail- Email verificationphone- Phone verificationpoa- Proof of addressquestionnaire- Questionnaire step
Channel Values
Thechannel field in code_sent can be:
email- Code sent via emailsms- Code sent via SMSwhatsapp- Code sent via WhatsApp
Code Size
ThecodeSize field in code_sent indicates the OTP code length (e.g., 4 or 6 digits).