@auth0/nextjs-auth0 - v4.9.0
    Preparing search index...

    Type Alias WithPageAuthRequiredPageRouter

    WithPageAuthRequiredPageRouter: <
        P extends { [key: string]: any } = { [key: string]: any },
        Q extends ParsedUrlQuery = ParsedUrlQuery,
    >(
        opts?: WithPageAuthRequiredPageRouterOptions<P, Q>,
    ) => PageRoute<P, Q>

    Wrap your getServerSideProps with this method to make sure the user is authenticated before visiting the page.

    // pages/protected-page.js
    import { auth0 } from "@/lib/auth0";

    export default function ProtectedPage() {
    return <div>Protected content</div>;
    }

    export const getServerSideProps = auth0.withPageAuthRequired();

    If the user visits /protected-page without a valid session, it will redirect the user to the login page. Then they will be returned to /protected-page after login.

    Type declaration