1. Knowledge Base
  2. iComply API Documentation

React.js Integration

This section described how to integrate the Natural Person Into a React.js application.

Our Natural Person is JavaScript based and therefore the steps to integrate it into a React.js application are a little different than integrating it into a dynamic website or HTML page.

const useScript = url => {
useEffect(() => {
const script = document.createElement('script');
script.src = url;
script.async = true;
script.onload = () => {
window.iComply.init(document.getElementById('iComply'), {
callback(serverResponse) {
fetch('${API}/icomplyListener', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: 'Bearer ${AT}',
},
body: JSON.stringify(serverResponse),
}).then(res =>
serverResponse.summaryResult == 'PASS'
? window.confirm('Automated ID Verification successful.') &&
window.location.replace('${APP_URL}/oauth/auth?response_type=code&scope=signature&client_&redirect_uri=${APP}/signup'),
: window.confirm('Automated ID Verification unsuccessful.'),
);
},
verificationIdCallback: function (verificationId) {
console.log(verificationId)
}
});
};
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
};
}, [url]);
};
useScript('https://verify.icomplykyc.com/icomply-min.js');
 

Please note this is just an example of how the iComply Natural Person Portal scripts can be integrated into a React.js application. Your exact implementation will vary depending on your application logic and onboarding funnel.