MonoCloud Authentication SDK
    Preparing search index...
    • Hook for getting the user's profile on client components

      Returns AuthState

      Authentication State

      "use client";

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

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

      return <>User Id: {user?.sub}</>;
      }

      Calling refetch(true) will force refresh the user's profile from the userinfo endpoint. If you do not intent to refersh from your tenants userinfo endpoint, use just refetch()

      Note⚠️: You need to set the env MONOCLOUD_AUTH_ALLOW_QUERY_PARAM_OVERRIDES=true or allowQueryParamOverrides should be true in the client initialization for force refresh to work

      "use client";

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

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

      return (
      <>
      <pre>{JSON.stringify(user)}</pre>
      <button onClick={() => refetch(true)}>Refresh</button>
      </>
      );
      }
      import { useAuth } from "@monocloud/auth-nextjs/client";

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

      return <>User Id: {user?.sub}</>;
      }

      Calling refetch(true) will force refresh the user's profile from the userinfo endpoint. If you do not intent to refersh from your tenants userinfo endpoint, use just refetch()

      Note⚠️: You need to set the env MONOCLOUD_AUTH_ALLOW_QUERY_PARAM_OVERRIDES=true or allowQueryParamOverrides should be true in the client initialization for force refresh to work

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

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

      return (
      <>
      <pre>{JSON.stringify(user)}</pre>
      <button onClick={() => refetch(true)}>Refresh</button>
      </>
      );
      }