createAuthHooks
createAuthHooks(
authentication):CreateAuthHooksReturn
Defined in: react/src/hooks/createAuthHooks.ts:64
Create authentication hooks for managing user sessions with Internet Identity.
Parameters
Section titled “Parameters”authentication
Section titled “authentication”Returns
Section titled “Returns”Example
Section titled “Example”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>}