Use this to customize the default login handler without overriding it. You can still override the handler if needed.

Example

Pass an options object

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

export default handleAuth({
login: handleLogin({
authorizationParams: { connection: 'github' }
})
});

Example

Pass a function that receives the request and returns an options object

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

export default handleAuth({
login: handleLogin((req) => {
return {
authorizationParams: { connection: 'github' }
};
})
});

This is useful for generating options that depend on values from the request.

Example

Override the login handler

import { handleAuth, handleLogin } from '@auth0/nextjs-auth0';

export default handleAuth({
login: async (req, res) => {
try {
await handleLogin(req, res, {
authorizationParams: { connection: 'github' }
});
} catch (error) {
console.error(error);
}
}
});