# Next.js 14 App router - catching callback error

**URL:** <https://community.auth0.com/t/next-js-14-app-router-catching-callback-error/154469>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [November 27, 2024, 2:08pm UTC](https://community.auth0.com/t/next-js-14-app-router-catching-callback-error/154469 "2024-11-27T14:08:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mihai.h](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mihai.h/32/60711_2.png) [@mihai.h](https://community.auth0.com/u/mihai.h)\
**Post date:** [November 27, 2024, 2:08pm UTC](https://community.auth0.com/t/next-js-14-app-router-catching-callback-error/154469/1 "2024-11-27T14:08:54Z")

</div>

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:

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

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

```

Thanks!

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [December 3, 2024, 2:14am UTC](https://community.auth0.com/t/next-js-14-app-router-catching-callback-error/154469/3 "2024-12-03T02:14:17Z")

</div>

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](https://auth0.github.io/nextjs-auth0/types/handlers_callback.AfterCallback.html) documentation.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 14, 2025, 4:56pm UTC](https://community.auth0.com/t/next-js-14-app-router-catching-callback-error/154469/4 "2025-01-14T16:56:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
