Auth Hooks
All auth hooks use TanStack Query mutations/queries for automatic loading states and error handling.
Hooks Reference
Section titled “Hooks Reference”useLogin()
Section titled “useLogin()”const { mutate, isPending } = useLogin();mutate({ email: 'admin@example.com', password: 'secret' });useLogout()
Section titled “useLogout()”const { mutate } = useLogout();mutate(); // Redirects to /loginuseGetIdentity()
Section titled “useGetIdentity()”const query = useGetIdentity();// query.data → { id: '1', name: 'Admin', avatar: '...' } | nulluseIsAuthenticated()
Section titled “useIsAuthenticated()”const { isAuthenticated, isLoading } = useIsAuthenticated();usePermissions<T>()
Section titled “usePermissions<T>()”const { data } = usePermissions<string[]>();// data → ['admin', 'editor']useOnError()
Section titled “useOnError()”const { mutate } = useOnError();mutate(error); // Calls authProvider.onError → may logout or redirectuseRegister(), useForgotPassword(), useUpdatePassword()
Section titled “useRegister(), useForgotPassword(), useUpdatePassword()”Same mutation pattern as useLogin().