Getting StartedBasic Usage

Basic Usage in React

import React, { useState } from 'react'
import { IdValidation } from 'idmission-web-sdk'
 
async function getSessionId() {
  try {
    const resp = await fetch('/my-api/get-session')
    return (await resp.json())?.id
  } catch (e) {
    console.error('failed to get session id', e)
  }
}
 
function MyComponent() {
  const [running, setRunning] = useState(false)
 
  return (
    <>
      <button onClick={() => setRunning(true)}>Start ID Validation</button>
      {running && <IdValidation sessionId={getSessionId} />}
    </>
  )
}

Basic Usage in HTML

Add the following script tag to your page’s <head>:

<script type="module" src="https://websdk-cdn-dev.idmission.com/websdk/prod/loader.js"></script>

You may subscribe to the idmission-web-sdk.ready event to be notified when loading has completed.

<script type="module">
    document.addEventListener('idmission-web-sdk.ready', () => {
      // this code fires when the sdk has finished loading.
    })
</script>

Then you may call any render method below, for example renderIdValidation, like so:

<button id="start-btn">Start ID Validation</button>
 
<div id="target-element"></div>
 
<script type="module">
  document.getElementById('start-btn').onclick = () => {
    // you should fetch a new session id from your server here (or earlier).
    fetch('/my-api/get-session').then(resp => resp.json()).then(({ id }) => {
      IDmissionSDK.renderIdValidation('#target-element', { sessionId: id });
    })
  }
</script>