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
Install Node.js https://nodejs.org
If you don’t have an existing project - create one
npx create-next-app@latest
// next.jsnpm create vite@latest
// vanilla js/react/vue/svelte/etc- (works best with modern javascript frameworks like next.js and bundlers like vite/webpack)
Download veryfi-lens-wasm package
- Run
npm install veryfi-lens-wasm@latest
- Run
Required Setup Steps
- Copy WASM files:
cp -r node_modules/veryfi-lens-wasm/wasm public/
- Copy WASM files:
Configure Headers
- Vite
- Next.js
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',
}
}
};
Next.js Example (next.config.js)
note
Create next.config.js in the root of your project if it doesn't exist
module.exports = {
async headers() {
return [
{
source: "/(.*)",
headers: [
{
key: "Cross-Origin-Opener-Policy",
value: "same-origin",
},
{
key: "Cross-Origin-Embedder-Policy",
value: "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';