# Basic Usage in React



## Scope and provenance

- Product: web
- Status: Imported reference snapshot. Import date is not a verification date or guarantee of current release support.
- SDK version: Not declared for this page. Versions in examples must not be assumed current.
- Environment: Page-specific. Confirm the environment host, credentials, and service configuration; do not infer them from another product.
- Source: https://websdk2docs.idmission.com/getting-started/basic-usage
- Imported at: 2026-10-21T17:27:01.149Z
- Canonical page: https://docs.idmission.com/web/getting-started/basic-usage
- Agent index: https://docs.idmission.com/llms.txt

---

<a id="basic-usage-in-react"></a>

### Basic Usage in React

```jsx
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} />}
    </>
  )
}
```

<a id="basic-usage-in-html"></a>

### Basic Usage in HTML

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

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

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

```html
<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:

```html
<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>
```
