Javascript
The Javascript SDK handles the redirect to the Uniqueness UI and callback.
Verisoul provides a React SDK via NPM. The NPM package is currently private, please reach out for an NPM token.
Add the NPM Token to your
.npmrc
file before installing the package. //registry.npmjs.org/:_authToken=<PUT_NPM_TOKEN_HERE>
registry=https://registry.npmjs.org/
always-auth=true
Install the Verisoul NPM package using the command below
$ npm i verisoul
React SDK Properties
prop | type | description |
---|---|---|
session | String (Required) | Verisoul sessionId |
onComplete | Function (Optional) | Callback to handle a completed session |
environment | String (Required) | { sandbox , prod } |
Example usage of the React SDK
import React, {useEffect, useState} from 'react';
import Verisoul from '@verisoul/ui';
const App = () => {
const [sessionToken, setSessionToken] = useState();
useEffect(() => {
if (!sessionToken) {
fetch(`${YOUR_SERVER}/create-token`)
.then(response => response.json())
.then(({sessionToken}) => setSessionToken(sessionToken))
.catch(err => console.error(err));
}
}, []);
const eventHandler = async (event) => {
if (event?.step === 'Complete') {
let {account_id} = event?.data
await fetch(`${YOUR_SERVER}/enroll/${account_id}`)
}
}
if (sessionToken) {
return (<Verisoul session={sessionToken}
onComplete={eventHandler}
environment={'sandbox'}/>)
} else {
return (<h4>Loading...</h4>)
}
}
export default App;
Last modified 2mo ago