The Onfido SDK for Front-end JavaScript
The Onfido Smart Capture SDKs provide a set of screens and functionality allowing applications to implement user identity verification flows. Each SDK contains:
All Onfido Smart Capture SDKs are orchestrated using Onfido Studio workflows with only minor customization differences between the available platforms.
The Onfido Web SDK is specifically designed for integrating web applications and easily managing cross-device experiences.
Two environments exist to support the Onfido SDK integrations:
The environment being used is determined by the API token that is used to generate the necessary SDK token.
Once you are satisfied with your integration and are ready to go live, please contact Onfido's Customer Support to obtain a live API token. You will have to replace the sandbox token in your code with the live token.
Check that you have entered correct billing details inside your Onfido Dashboard, before going live.
The Onfido Web SDK can be added to your project in two ways:
script tag or as an importTo benefit from the latest features and patches released by Onfido and minimize the size of the script used, it is highly recommended to use an integration method that leverages the Onfido CDN, as detailed in the following sections.
Note that while Onfido hosts the CDN and ensures the script availability at runtime, any project using the SDK library from NPM would require its hosting.
The quickest and simplest way to integrate the Onfido Web SDK is to use the Onfido-hosted library.
From SDK 12.3.1 onwards, the version number you subscribe to can vary, depending on your needs:
v14) means Onfido will update to the latest available patch and minor releasev14.11) means Onfido will update to the latest available patch releasev14.11.0) will fix the library files to that SDK releasescript tagNote that prior to version 12.3.1, the CDN path was https://assets.onfido.com/web-sdk-releases//onfido.min.js.
Also note that from version 14 onwards, a separate stylesheet is no longer required as it will be included with the default library.
import directiveThe library can also be invoked directly within an object or component:
// ES6 module import
import { Onfido } from 'onfido-sdk-ui'
// commonjs style require
var Onfido = require('onfido-sdk-ui').OnfidoThe CSS style will be included inline with the JS code when the library is imported.
Note: The library is Browser only, it does not support the Node Context.
NPM is a public repository of libraries available for download and integration into web/native apps. Onfido has been publishing all its SDKs there for convenience to customers.
From version 14 onwards, the onfido-sdk-ui package loads the Web SDK at runtime from the Entrust CDN. By default, npm integrations use Entrust Managed SDK Upgrades, which means Entrust manages the runtime SDK version delivered to your integration within the latest major version. This means you get continuous improvements with lower maintenance effort, backed by progressive rollouts and automated monitoring.
If you need full version control, you can optionally specify a major, minor, or patch version in Onfido.init(). See the Version pinning section below for details.
The Web SDK version 14 maintains the existing package name:
npm install onfido-sdk-uior
yarn add onfido-sdk-uiFrom version 14 onwards, in addition to the benefits of CDN delivery, core functions are also typed when used with TypeScript.
From version 14 onwards, "split bundles" are no longer supported. Onfido recommends the use of either the direct or NPM CDN integration.
Since version 6.5.0, TypeScript is officially supported.
Available types:
OnfidoApi - The base type for the Onfido objectSdkParameters - The parameters passed into Onfido.init()⚠️ The following SDK initialization documentation applies to identity verification workflows orchestrated using Onfido Studio. For integrations where the verification steps are manually defined and configured, please refer to the Advanced flow customization section below.
The Web SDK has multiple initialization and customization options that provide flexibility to your integration, while remaining easy to integrate.
Note that from version 14, it will no longer be possible to change initialization options at runtime as was previously allowed with the setOption() function.
Onfido Studio is the platform used to create highly reusable identity verification workflows for use with the Onfido SDKs. For an introduction to working with workflows, please refer to our Getting Started guide, or the Onfido Studio product guide.
SDK sessions are orchestrated by a session-specific workflow_run_id, itself derived from a workflow_id, the unique identifier of a given workflow.
For details on how to generate a workflow_run_id, please refer to the POST /workflow_runs/ endpoint definition in the Onfido API reference.
Note that in the context of the SDK the
workflow_run_idproperty is referred to asworkflowRunId.
The SDK is authenticated using SDK tokens. Onfido Studio generates and exposes SDK tokens in the workflow run payload returned by the API when a workflow run is created.
SDK tokens for Studio can only be used together with the specific workflow run they are generated for, and remain valid for a period of five weeks.
Note: You must never use API tokens in the frontend of your application as malicious users could discover them in your source code. You should only use them on your server.
To load the Onfido flow, add an empty HTML element for the modal interface to mount itself on:
Note: Starting from Web SDK v14.0.0, the SDK container will automatically inherit 100% of the height and width of its parent wrapper. On desktop, it will be constrained by a maximum width of 600px and a maximum height of 800px.
If you are embedding the SDK within a div, iframe, or any other element, ensure that you adjust the dimensions of the parent container to meet your specific requirements.
With the configuration in an accompanying script:
Onfido.init({
token: '',
containerId: 'onfido-mount',
//containerEl:
The Web SDK creates a single cookie - 'onfido-web-sdk-analytics' - containing a randomly generated UUID used only for internal analytics purposes. This identifier helps Entrust link together multiple verification sessions associated with the same end user, particularly when a single end user has multiple applicant ids instead of reusing the recommended single applicant profile.
The cookie persists for 30 days, but can be disabled using the 'disableAnalyticsCookies' option, removing the cookie if it already exists.
| Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
The SDK is compatible with the all supported Node.js versions (currently starting with Node.js 16).
The Onfido SDK has been optimized to provide the following accessibility support by default:
Refer to our accessibility statement for more details.
⚠️ Note: If you make your own UI customizations, you are responsible for ensuring that the UI changes will still adhere to accessibility standards. For example, accessible color contrast ratios and dyslexic friendly fonts.
For guide on CSP common issue and recommendations, please refer to the guide Onfido Web SDKn and Content Security Policy (CSP) guide.
For instruction and guide on how to embed the Onfido Web SDK in an iFrame, please refer to the guide Using the Onfido web SDK in an iFrame.
Onfido Web SDK versions <13.0.0 had a parameter named uploadFallback that could be set on both the document step and the face step. This parameter allowed clients to present end-users with a file input capability during the SDK flow.
With Web SDK 14.15 and ab
No open issues yet, or sync has not completed.