react-utils - v1.0.31
    Preparing search index...

    Function useAuthHook

    • Custom hook for handling authentication state and token validation.

      Returns AuthHookResult

      An object containing:

      • user: The authenticated user object or null
      • isLoading: Boolean indicating if auth check is in progress
      • error: Error object if authentication failed

      Munir Mardinli

      2025-06-06

      // Basic usage
      const { user, isLoading, error } = useAuthHook();
      // With TypeScript generics for custom user type
      interface CustomUser extends User<{ email: string }> {}
      const { user } = useAuthHook<CustomUser>();
      • AuthHookResult for return type structure
      • User for base user type that can be extended