useAuth
Read and mutate Casino-platform auth state (login, register, Google sign-in, logout, token refresh).
import { useAuth } from 'flowstack-sdk'useAuth() is for Casino platform internals. Built apps must NOT use it — they authenticate via BrokeredLoginButton and read auth state from useFlowstack() instead. Calling login(email, password) from a built app always fails because end-users don't have Casino credentials.
Signature
const { user, credentials, isAuthenticated, isLoading, error, login, register, googleSignIn, logout, refreshToken } = useAuth()Returns
| Field | Type | Description |
|---|---|---|
user | User | null | The authenticated user, or null. |
credentials | FlowstackCredentials | null | Active session credentials. |
isAuthenticated | boolean | Whether a session is active. |
isLoading | boolean | Auth request in flight. |
error | string | null | Last auth error message. |
login | (email: string, password: string) => Promise<boolean> | Casino platform only — password login. |
register | (email: string, password: string, name?: string) => Promise<boolean> | Casino platform only — create an account. |
googleSignIn | () => Promise<void> | Casino platform only — Google OAuth. |
logout | () => void | Clear the session. |
refreshToken | () => Promise<boolean> | Refresh the access token. |
Examples
Built apps — read auth state instead
const { isAuthenticated, isInitialized, credentials } = useFlowstack();WarningBuilt apps: do not use this hook. Read auth state from
useFlowstack() (isAuthenticated, isInitialized, credentials) and authenticate via BrokeredLoginButton.See also
BrokeredLoginButton · useFlowstackStatus · AuthGuard
Source: README.md#useauth · Also available in llms-full.txt and registry.json.