Skip to main content

Setup

info

Cross-Origin Isolation Requirement

The SDK uses SharedArrayBuffer for efficient processing, which requires cross-origin isolation. Your application must set the following headers:

  • Cross-Origin-Opener-Policy: same-origin
  • Cross-Origin-Embedder-Policy: require-corp

You can learn more about cross-origin isolation here.

Installation

  1. Install Node.js https://nodejs.org

  2. If you don’t have an existing project - create one

    • npx create-next-app@latest // next.js
    • npm create vite@latest // vanilla js/react/vue/svelte/etc
    • (works best with modern javascript frameworks like next.js and bundlers like vite/webpack)
  3. Download veryfi-lens-wasm package

    • Run npm install veryfi-lens-wasm@latest
  4. Required Setup Steps

    • Copy WASM files:
      • cp -r node_modules/veryfi-lens-wasm/wasm public/

Configure Headers

Vite Example (vite.config.js)

note

Create vite.config.js in the root of your project if it doesn't exist

export default {
server: {
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
}
}
};

Import the SDK

Import the SDK to your js file (index.js, main.js or your component where you want to initialize lens):

import VeryfiLens from 'veryfi-lens-wasm';