WithPageAuthRequiredPageRouter: (<P, Q>(opts?) => PageRoute<P, Q>)

Type declaration

    • <P, Q>(opts?): 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 { withPageAuthRequired } from '@auth0/nextjs-auth0';

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

      export const getServerSideProps = 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 Parameters

      • P extends {
            [key: string]: any;
        } = {
            [key: string]: any;
        }

      • Q extends ParsedUrlQuery = ParsedUrlQuery

      Parameters

      Returns PageRoute<P, Q>