MonoCloud Authentication SDK
    Preparing search index...
    • A wrapper component that conditionally renders its children based on the user's authentication status and group membership.

      Note⚠️: The component is hidden from view. The data is present in the browser. Use server side protectPage() for protecting components before that data is sent to the client.

      Parameters

      Returns Element | null

      The children if authorized, the onAccessDenied content if unauthorized, or null while loading.

      "use client";

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

      export default function Home() {
      return (
      <Protected onAccessDenied={<>Sign in to view the message.</>}>
      <>You are breathtaking</>
      </Protected>
      );
      }

      See ProtectedComponentProps.

      "use client";

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

      export default function Home() {
      return (
      <Protected
      onAccessDenied={<>Only admins are allowed.</>}
      groups={["admin"]}
      >
      <>Signed in as admin</>
      </Protected>
      );
      }
      import { Protected } from "@monocloud/auth-nextjs/components/client";

      export default function Home() {
      return (
      <Protected onAccessDenied={<>Sign in to view the message.</>}>
      <>You are breathtaking</>
      </Protected>
      );
      }

      See ProtectedComponentProps.

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

      export default function Home() {
      return (
      <Protected
      onAccessDenied={<>Only admins are allowed.</>}
      groups={["admin"]}
      >
      <>Signed in as admin</>
      </Protected>
      );
      }