• The main way to use the server SDK.

    Page Router

    Simply set the environment variables per ConfigParameters then create the file pages/api/auth/[auth0].js. For example:

    // pages/api/auth/[auth0].js
    import { handleAuth } from '@auth0/nextjs-auth0';

    export default handleAuth();

    App Router

    Simply set the environment variables per ConfigParameters then create the file app/api/auth/[auth0]/route.js. For example:

    // app/api/auth/[auth0]/route.js
    import { handleAuth } from '@auth0/nextjs-auth0';

    export const GET = handleAuth();

    This will create 5 handlers for the following urls:

    • /api/auth/login: log the user in to your app by redirecting them to your identity provider.
    • /api/auth/callback: The page that your identity provider will redirect the user back to on login.
    • /api/auth/logout: log the user out of your app.
    • /api/auth/me: View the user profile JSON (used by the UseUser hook).

    Parameters

    Returns any