Skip to main content
The Didit JavaScript SDK provides a programmatic way to integrate verification into your web application with full control over the user experience.

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: Use your workflow’s UniLink URL directly from the Didit Console. No backend required.
Get your UniLink URL from the Didit Console → Your Workflow → Copy Link. The session_id generated will be sent to you by an event. Check event reference here Your backend creates a session via the Didit API and returns the hosted verification URL. This gives you control over vendor_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)
Frontend
The session-create response field is named url (see the Create Session OpenAPI schema). Pass it directly to startVerification({ url }).

Configuration

See the full TypeScript type definitions below for the complete DiditSdkConfiguration interface.

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).
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 the onEvent callback:

Event Reference

Step Values

The step field can be one of:
  • document_selection - Document type selection
  • document_front - Front side of document
  • document_back - Back side of document
  • face - Face/liveness verification
  • email - Email verification
  • phone - Phone verification
  • poa - Proof of address
  • questionnaire - Questionnaire step

Channel Values

The channel field in code_sent can be:
  • email - Code sent via email
  • sms - Code sent via SMS
  • whatsapp - Code sent via WhatsApp

Code Size

The codeSize field in code_sent indicates the OTP code length (e.g., 4 or 6 digits).

TypeScript Types