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)
The latest published npm release is
0.4.0. Upgrade for the camera options the native SDKs already offer, including defaultLivenessCamera, which opens the face capture on the rear camera (see Camera options). 0.3.1 brought correct modal sizing on short and landscape viewports, embedded mode that fills its own container, and an accurate SDK_VERSION export.Check the installed version
Your package manager remains authoritative for the installed release:0.3.1 this export is generated from the package version in every JavaScript format (ESM, CommonJS, UMD, minified UMD) and in the TypeScript declaration, so it always matches the installed release.
0.3.0 and earlier report 0.2.1 from this export regardless of the installed version. On those releases, use npm list or your lockfile instead.
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 hosted verification URL. This gives you control overvendor_data, per-session callback, metadata, and lets you create sessions before the user reaches the frontend.
Read more in the Create Session API reference.
Backend (Node.js / Express)
The session-create response field is named
url (see the Create Session OpenAPI schema). Pass it directly to startVerification({ url }).Configuration
Camera options
The camera options require
@didit-protocol/sdk-web 0.4.0 or later.defaultLivenessCamera: 'back' to open the face capture on the rear camera, for example on a kiosk or when an operator holds the device and points it at the person being verified.
- Accepted lens values are
'front'and'back'. Any other value is ignored, as is a switcher flag that is not a boolean. - A device without the requested camera keeps the one it has: a laptop asked for
'back'still uses its webcam. The switcher is hidden on single-camera devices whatever the flags say. - The liveness options apply to the passive liveness check. Active liveness is not affected.
- The SDK forwards the options to the verification page as query parameters of the verification URL:
document_camera,liveness_camera,document_camera_switchandliveness_camera_switch. If you open the verification URL directly instead of through the SDK, set them yourself: append?liveness_camera=backto a URL without a query string,&liveness_camera=backto one that already has parameters, or set them with theURLAPI so either case is handled:
Modal sizing and scrolling
The sizing behavior below requires 0.3.1 or later. 0.3.0 and earlier can clip the verification flow on short desktop and landscape viewports.
dvh on browsers that support dynamic viewport units and falls back to vh on older supported browsers. At widths of 540px and below, the modal fills the visible viewport. The close button and exit confirmation stay inside the modal.
Embedded mode
Embedded mode does not use the modal’s 500px by 700px cap. The SDK fills the host element’s content box, so give that element an explicit or otherwise resolved height:Verification Results
The SDK returns three types of results:Completed
Verification flow finished (approved, pending, or declined).The TypeScript type declares
'Approved' | 'Pending' | 'Declined', but the value is passed through from the hosted flow’s session status — you can also receive other statuses such as In Review. Pending is the SDK’s fallback when the flow reported no status. Treat status as a hint and rely on the webhook for the canonical decision.Cancelled
User closed the verification modal.session is included when a sessionId was already known (it can be undefined if the user cancelled before the iframe reported one).
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
Properties
Callbacks
Granular Events
Track verification progress with theonEvent callback:
Event Reference
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).