# createAuthHooks

> **createAuthHooks**(`authentication`): [`CreateAuthHooksReturn`](https://ic-reactor.b3pay.net/v3/libs/interfaces/createauthhooksreturn/)

Defined in: [react/src/hooks/createAuthHooks.ts:64](https://github.com/B3Pay/ic-reactor/blob/70bedf3c8779611a3b35710510442dee7f630b87/packages/react/src/hooks/createAuthHooks.ts#L64)

Create authentication hooks for managing user sessions with Internet Identity.

## Parameters

### authentication

[`AuthenticationManager`](https://ic-reactor.b3pay.net/v3/libs/classes/authenticationmanager/)

## Returns

[`CreateAuthHooksReturn`](https://ic-reactor.b3pay.net/v3/libs/interfaces/createauthhooksreturn/)

## Example

```ts
const { useAuth, useUserPrincipal, useAgentState } = createAuthHooks(authentication)

function App() {
  const { login, logout, principal, isAuthenticated } = useAuth()

  return isAuthenticated
    ? <button onClick={() => logout()}>Logout {principal?.toText()}</button>
    : <button onClick={() => login()}>Login with II</button>
}
```