The component to protect.
Optionaloptions: ProtectPageOptionsThe options.
Protected client rendered page component.
"use client";
import { protectPage } from "@monocloud/auth-nextjs/client";
export default protectPage(function Home() {
return <>You are signed in</>;
});
See ProtectPageOptions for more options.
"use client";
import { protectPage } from "@monocloud/auth-nextjs/client";
export default protectPage(
function Home() {
return <>You are signed in</>;
},
{ returnUrl: "/dashboard", authParams: { loginHint: "username" } }
);
import { protectPage } from "@monocloud/auth-nextjs/client";
export default protectPage(function Home() {
return <>You are signed in</>;
});
See ProtectPageOptions for more options.
import { protectPage } from "@monocloud/auth-nextjs/client";
export default protectPage(
function Home() {
return <>You are signed in</>;
},
{ returnUrl: "/dashboard", authParams: { loginHint: "username" } }
);
Function to protect a client rendered page component. Ensures that only authenticated users can access the component.
Note⚠️: Since
window.locationis set asreturnUrlquery param by default, you need to set the envMONOCLOUD_AUTH_ALLOW_QUERY_PARAM_OVERRIDES=trueorallowQueryParamOverridesshould betruein the client initialization for returning to the same page.