• Public
  • Public/Protected
  • All

Module handlers/auth


Server Interfaces

Server Type aliases

Server Type aliases


HandleAuth: (userHandlers?: Partial<Handlers>) => NextApiHandler

The main way to use the server SDK.

Simply set the environment variables per {@link Config} then create the file pages/api/auth/[...auth0].js, eg

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

export default handleAuth();

This will create 4 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)

Type declaration

    • (userHandlers?: Partial<Handlers>): NextApiHandler
    • Parameters

      • Optional userHandlers: Partial<Handlers>

      Returns NextApiHandler