Next.js 14 App router - catching callback error

Hi! I have a Next.js 14 app using Auth0 Universal Login. How can I handle errors in the Auth0 callback and redirect users to a /maintenance route if something goes wrong?

Here’s my current route.ts file:

import { handleAuth, handleProfile } from "@auth0/nextjs-auth0";

export const GET = handleAuth({
    'silent': handleProfile({ refetch: true })
  })

Thanks!

Hi @mihai.h,

Welcome to the Auth0 Community!

You can use the callback handler to redirect if a login issue occurs after reaching the callback URL, using the AfterCallback hook.

Please refer to the AfterCallback | @auth0/nextjs-auth0 documentation.

Thanks,
Rueben