> For the complete documentation index, see [llms.txt](/llms.txt).

# useIdentityToken

Hook to retrieve and manage the identity token from Embedded Wallets.

### Import[​](#import "Direct link to Import")

```
import { useIdentityToken } from '@web3auth/modal/react'

```

### Usage[​](#usage "Direct link to Usage")

```
import { useIdentityToken } from '@web3auth/modal/react'

function IdentitytTokenButton() {
  const { getIdentityToken, loading, error, token } = useIdentityToken()

  return (
    <div>
      <button onClick={() => getIdentityToken()} disabled={loading}>
        {loading ? 'Authenticating...' : 'Get Identity Token'}
      </button>
      {token && <div>Token: {token}</div>}
      {error && <div>Error: {error.message}</div>}
    </div>
  )
}

```

### Return type[​](#return-type "Direct link to Return type")

```
import { type IUseIdentityToken } from '@web3auth/modal/react'

```

#### `loading`[​](#loading "Direct link to loading")

`boolean`

Whether the authentication process is in progress.

#### `error`[​](#error "Direct link to error")

`Web3AuthError | null`

Error that occurred during the authentication process.

#### `token`[​](#token "Direct link to token")

`string | null`

The identity token returned after successful authentication.

#### `getIdentityToken`[​](#getidentitytoken "Direct link to getidentitytoken")

`() => Promise<string | null>`

Function to initiate the authentication process and retrieve the identity token.
