Props of the protected component (excluding user).
The page component to protect
Optionaloptions: ProtectClientPageOptionsOptional configuration
A protected React component.
"use client";
import { protectClientPage } from "@monocloud/auth-nextjs/client";
export default protectClientPage(function Home({ user }) {
return <>Signed in as {user.email}</>;
});
"use client";
import { protectClientPage } from "@monocloud/auth-nextjs/client";
export default protectClientPage(
function Home({ user }) {
return <>Signed in as {user.email}</>;
},
{
returnUrl: "/dashboard",
authParams: { loginHint: "user@example.com" }
}
);
"use client";
import { protectClientPage } from "@monocloud/auth-nextjs/client";
export default protectClientPage(
function Home({ user }) {
return <>Signed in as {user.email}</>;
},
{
onAccessDenied: () => <div>Please sign in to continue</div>
}
);
"use client";
import { protectClientPage } from "@monocloud/auth-nextjs/client";
export default protectClientPage(
function Home({ user }) {
return <>Welcome Admin {user.email}</>;
},
{
groups: ["admin"],
onGroupAccessDenied: (user) => <div>User {user.email} is not an admin</div>
}
);
protectClientPage()wraps a client-rendered page component and ensures that only authenticated users can access it.If the user is authenticated, the wrapped component receives a
userprop.