Function: useAuth()
useAuth():
AuthContextValue
Defined in: web/lib/auth/auth-context.tsx:320
Hook to access auth context.
Returns
Auth context value
Remarks
Must be used within an AuthProvider.
Throws
Error if used outside AuthProvider
Example
function MyComponent() {
const { isAuthenticated, user, login, logout } = useAuth();
if (!isAuthenticated) {
return <button onClick={() => login({ handle: '' })}>Login</button>;
}
return <div>Welcome, {user?.displayName}</div>;
}