Integrate Identity Verification with the Didit JavaScript SDK
Learn how to seamlessly integrate identity verification into your web application using the Didit JavaScript SDK. This guide covers installation, setup, and implementation with code examples, ensuring a smooth and secure user.

Easy IntegrationThe Didit JavaScript SDK offers a simple API and flexible integration methods, allowing you to quickly add identity verification to your web application.
Enhanced SecurityUtilize Didit's advanced features like ID Verification and Liveness Detection to protect against fraud and ensure secure user onboarding.
Customizable ExperienceConfigure the SDK to match your application's look and feel, providing a seamless and consistent user experience.
Free Core KYCDidit provides a free tier, enabling you to start verifying identities without upfront costs, leveraging our AI-native, modular platform.
Introduction to the Didit JavaScript SDK
The Didit JavaScript SDK provides a programmatic way to integrate identity verification directly into your web applications, offering full control over the user experience. Whether you're building a React, Angular, or vanilla JavaScript application, the SDK simplifies the process of verifying user identities, enhancing security, and ensuring compliance. With Didit's AI-native platform, you can leverage features like ID Verification, Passive & Active Liveness, and more, all through a clean and easy-to-use API.Installation and Setup
Before you begin, ensure you have a Didit account and have created a workflow in the Didit Console. The SDK can be installed via NPM, Yarn, or directly through a CDN. Here’s how to get started:NPM/Yarn
To install using NPM or Yarn, run the following command: ```bash npm install @didit-protocol/sdk-web # or yarn add @didit-protocol/sdk-web ```CDN (UMD)
Alternatively, you can include the SDK directly in your HTML file using a CDN: ```html ```Implementing Identity Verification
Once installed, you can implement identity verification in your application. Here’s a basic example using vanilla JavaScript: ```html ``` This code snippet demonstrates how to initialize the SDK, set up a completion callback, and start the verification process using a UniLink URL. The UniLink URL can be obtained from the Didit Console.Advanced Configuration and Customization
The Didit JavaScript SDK offers various configuration options to tailor the verification process to your specific needs. You can enable logging for debugging, customize the container element for the modal, and set the z-index. Here’s an example of advanced configuration: ```typescript DiditSdk.shared.startVerification({ url: 'https://verify.didit.me/session/session-token', configuration: { loggingEnabled: true, zIndex: 10000, showCloseButton: false } }); ``` Furthermore, Didit’s modular architecture allows you to leverage specific identity primitives such as ID Verification (OCR, MRZ, barcodes), Passive & Active Liveness, and 1:1 Face Match, ensuring a comprehensive and secure verification process.Handling Verification Results
TheonComplete callback function is crucial for handling the results of the verification process. It provides information about whether the verification was completed successfully, cancelled, or failed. Here’s how you can handle the results:
```typescript
DiditSdk.shared.onComplete = (result) => {
switch (result.type) {
case 'completed':
console.log('Verification completed!');
console.log('Session ID:', result.session?.sessionId);
console.log('Status:', result.session?.status);
break;
case 'cancelled':
console.log('User cancelled verification');
break;
case 'failed':
console.error('Verification failed:', result.error?.message);
break;
}
};
```
This callback allows you to update your application's state, display appropriate messages to the user, and take any necessary actions based on the verification outcome. For instance, if you are verifying age, you can use Didit's Age Estimation feature alongside the ID Verification to ensure the user meets the required age threshold.
How Didit Helps
Didit simplifies identity verification with its AI-native, developer-first platform. Our modular architecture allows you to plug-and-play various identity checks, creating orchestrated workflows tailored to your specific needs. With Didit, you can automate trust and reduce manual review, saving time and resources. Key Didit products that enhance identity verification include: * ID Verification: Accurately extracts and validates data from various ID documents using OCR, MRZ parsing, and barcode decoding. * Passive & Active Liveness: Prevents fraud by ensuring the user is a real person and not a bot or a deepfake. * Age Estimation: Enables privacy-preserving age verification, crucial for industries requiring age compliance. Didit offers a Free Core KYC tier, allowing you to start verifying identities without setup fees. Our platform is designed to be global by design, ensuring compliance and security across different regions.Ready to Get Started?
Ready to see Didit in action? Get a free demo today.
Start verifying identities for free with Didit's free tier.