Sign in

Hook: useAuth

useAuth(): MonoCloudAuth

useAuth() is a client-side hook that exposes the current authentication state and actions provided by MonoCloudAuthProvider.

Returns

MonoCloudAuth

The current MonoCloudAuth.

Examples

src/Profile.tsx
"use client";

import { useAuth } from "@monocloud/auth-react";

export default function Home() {
  const { isLoading, isAuthenticated, user } = useAuth();

  if (isLoading) {
    return <>Loading...</>;
  }

  if (!isAuthenticated) {
    return <>Not signed in</>;
  }

  return <>User Id: {user?.sub}</>;
}
© 2024 MonoCloud. All rights reserved.