useAuth
Returns the current auth state and actions.
import { useAuth } from "@allem-sdk/auth";Returns
| Property | Type | Description |
|---|---|---|
| user | AuthUser | null | Current user or null |
| status | "loading" | "authenticated" | "unauthenticated" | Auth state |
| isAuthenticated | boolean | Shorthand check |
| isLoading | boolean | Shorthand check |
| signIn | (creds) => Promise | Sign in |
| signOut | () => Promise | Sign out |
Usage
const { user, status, signIn, signOut } = useAuth();
// Sign in
await signIn({ email: "user@example.com", password: "secret" });
// Check status
if (status === "loading") return <Spinner />;
if (status === "unauthenticated") return <LoginPage />;
// Use user data
<p>Welcome, {user?.name}</p>
<button onClick={signOut}>Sign Out</button>