# Dynamic Redirection from Login success

**URL:** <https://community.auth0.com/t/dynamic-redirection-from-login-success/114725>\
**Category:** Get Help\
**Tags:** signup-prompt-new-experience, login-experience\
**Created:** [August 29, 2023, 8:34am UTC](https://community.auth0.com/t/dynamic-redirection-from-login-success/114725 "2023-08-29T08:34:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TalhaRizwan093](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/talharizwan093/32/49005_2.png) [@TalhaRizwan093](https://community.auth0.com/u/TalhaRizwan093)\
**Post date:** [August 29, 2023, 8:34am UTC](https://community.auth0.com/t/dynamic-redirection-from-login-success/114725/1 "2023-08-29T08:34:15Z")

</div>

I have implemented authO in my Next13 app project. My login returns to root location now i want it to dynamic after success redirection currently i have this code in my route.js

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

export const GET = handleAuth({
  login: handleLogin({
    authorizationParams: {
      prompt: "login",
    },
    returnTo: "/",
  }),
  signup: handleLogin({
    authorizationParams: {
      prompt: "login",
      screen_hint: "signup",
    },
    returnTo: "/", // This is the default behavior
  }),
  loginFromProduct: handleLogin({
    authorizationParams: {
      prompt: "login",
    },
    returnTo: "/product-detail-2?id=1b2fec2c-d5f0-4ae9-a48b-67479f9b6ebb",
  }),
});

```

loginFromProduct should redirect back to the same product page currently i hardcoded it how can i make it dynamic i have the ids of product from where login button is activating

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [August 31, 2023, 2:20am UTC](https://community.auth0.com/t/dynamic-redirection-from-login-success/114725/3 "2023-08-31T02:20:45Z")

</div>

Hi @TalhaRizwan093

Welcome to the Auth0 Community!

In order to handle dynamic redirection from Login success you can use the `state` parameter to encode an application state that will put the user where they were before the authentication process started.

[Redirect users with state parameter](https://auth0.com/docs/secure/attack-protection/state-parameters#redirect-users:~:text=No-,Redirect%20users,-You%20can%20use)

Thanks,  
Dawid

---

<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:** [September 14, 2023, 2:21am UTC](https://community.auth0.com/t/dynamic-redirection-from-login-success/114725/4 "2023-09-14T02:21:37Z")

</div>

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