Docs / auth / useAuth

useAuth

hooksince 0.1.0not for built apps

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

FieldTypeDescription
userUser | nullThe authenticated user, or null.
credentialsFlowstackCredentials | nullActive session credentials.
isAuthenticatedbooleanWhether a session is active.
isLoadingbooleanAuth request in flight.
errorstring | nullLast 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() => voidClear 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.