useAuth

Returns the current auth state and actions.

import { useAuth } from "@allem-sdk/auth";

Returns

PropertyTypeDescription
userAuthUser | nullCurrent user or null
status"loading" | "authenticated" | "unauthenticated"Auth state
isAuthenticatedbooleanShorthand check
isLoadingbooleanShorthand check
signIn(creds) => PromiseSign in
signOut() => PromiseSign 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>