MonoCloud Authentication SDK
    Preparing search index...
    • Function to protect a client rendered page component. Ensures that only authenticated users can access the component.

      Note⚠️: Since window.location is set as returnUrl query param by default, you need to set the env MONOCLOUD_AUTH_ALLOW_QUERY_PARAM_OVERRIDES=true or allowQueryParamOverrides should be true in the client initialization for returning to the same page.

      Type Parameters

      • P extends object

      Parameters

      Returns FC<P>

      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" } }
      );