Skip to content
IC Reactor

createAuthHooks

createAuthHooks(authentication): CreateAuthHooksReturn

Defined in: react/src/hooks/createAuthHooks.ts:64

Create authentication hooks for managing user sessions with Internet Identity.

AuthenticationManager

CreateAuthHooksReturn

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>
}