Props for customizing the Protected component.
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>
);
}
"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>
);
}
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.