# How to redirect to specific path in Nextjs 14 app route after login?

**URL:** <https://community.auth0.com/t/how-to-redirect-to-specific-path-in-nextjs-14-app-route-after-login/147462>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [September 18, 2024, 12:25pm UTC](https://community.auth0.com/t/how-to-redirect-to-specific-path-in-nextjs-14-app-route-after-login/147462 "2024-09-18T12:25:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hongda.xie](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hongda.xie/32/60595_2.png) [@hongda.xie](https://community.auth0.com/u/hongda.xie)\
**Post date:** [September 18, 2024, 12:25pm UTC](https://community.auth0.com/t/how-to-redirect-to-specific-path-in-nextjs-14-app-route-after-login/147462/1 "2024-09-18T12:25:36Z")

</div>

Hi,

I’m using nextjs 14 with app route. I want to redirect the user to a specific path after login, such as `/dashboard`.  
In the api route:  
Firstly, I tried to add `returnTo` in handleLogin function, it doesn’t work.  
Then, I also tried to add afterCallback function to redirect user to the path according to [this document](https://auth0.github.io/nextjs-auth0/types/handlers_callback.AfterCallbackAppRoute.html) , it throw this error

 ![image](https://global.discourse-cdn.com/auth0/original/3X/7/a/7a738f26db8e5bbac0b44398d19df8812494242d.png)

Codes are below:

```auto
// app/api/auth/[auth0]/route.js
import { handleAuth, handleCallback, handleLogin } from "@auth0/nextjs-auth0";
import { redirect } from "next/navigation";

export const GET = handleAuth({
  // login: handleLogin({
  // returnTo: "/dashboard",
  // }),
  callback: handleCallback({
    afterCallback: () => {
      redirect("/dashboard");
    },
  }),
})

```

---

<div class="post-metadata">

**Author:** ![hongda.xie](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hongda.xie/32/60595_2.png) [@hongda.xie](https://community.auth0.com/u/hongda.xie)\
**Post date:** [September 26, 2024, 12:09am UTC](https://community.auth0.com/t/how-to-redirect-to-specific-path-in-nextjs-14-app-route-after-login/147462/2 "2024-09-26T00:09:03Z")

</div>

resolved by [Unable to navigate on afterCallback · Issue #1600 · auth0/nextjs-auth0 · GitHub](https://github.com/auth0/nextjs-auth0/issues/1600#issuecomment-1845422586)

---

<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:** [October 10, 2024, 12:09am UTC](https://community.auth0.com/t/how-to-redirect-to-specific-path-in-nextjs-14-app-route-after-login/147462/3 "2024-10-10T00:09:04Z")

</div>

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