# How do i redirect users to a page in my app after login using universal login with (next-js)

**URL:** <https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [May 17, 2023, 5:24pm UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199 "2023-05-17T17:24:16Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![adhamdoody7813](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adhamdoody7813/32/45544_2.png) [@adhamdoody7813](https://community.auth0.com/u/adhamdoody7813)\
**Post date:** [May 17, 2023, 5:24pm UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/1 "2023-05-17T17:24:16Z")

</div>

i wanted to redirected the user to my posts page in my app after they login using universal login how do i that with code ?

---

<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:** [May 17, 2023, 8:06pm UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/3 "2023-05-17T20:06:53Z")

</div>

Hi @adhamdoody7813,

Thanks for reaching out to the Auth0 Community!

To redirect your users to your posts page after they have logged in, please specify the redirect URL in the `redirect_uri` query parameter of the `/authorize` request.

For example:

```auto
https://{yourDomain}/authorize?
    response_type=code&
    client_id={yourClientId}&
    redirect_uri={YOUR_POSTS_PAGE_URL}&
    scope={scope}&
    audience={apiAudience}&
    state={state}

```

See [this documentation](https://auth0.com/docs/api/authentication#authorization-code-flow:~:text=redirect_uri-,The%20URL%20to%20which%20Auth0%20will%20redirect%20the%20browser%20after%20authorization%20has%20been%20granted%20by%20the%20user.,-connection) for more details.

Please let me know if you have any questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![adhamdoody7813](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adhamdoody7813/32/45544_2.png) [@adhamdoody7813](https://community.auth0.com/u/adhamdoody7813)\
**Post date:** [May 18, 2023, 4:43am UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/4 "2023-05-18T04:43:57Z")

</div>

i forgot to mention i am using next js @rueben.tiow

---

<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:** [May 19, 2023, 6:16pm UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/5 "2023-05-19T18:16:44Z")

</div>

Hi @adhamdoody7813,

Thank you for your response and clarification!

Using Auth0’s Next.js SDK, there are a couple of ways:

1. In your `config.ts` file, specify the `baseURL`  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/1/2/12ea05e06400b5531772922a7650777cb76fb5df.png)  
(Reference: [BaseConfig | @auth0/nextjs-auth0](https://auth0.github.io/nextjs-auth0/interfaces/config.BaseConfig.html#baseURL))
2. In your Login Handler, specify the `returnTo` property in the request.  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/7/f/7f7fa3812cdf50d13705ae5b6544717e965e8e02.png)  
(Reference: [LoginOptions | @auth0/nextjs-auth0](https://auth0.github.io/nextjs-auth0/interfaces/handlers_login.LoginOptions.html#returnTo))

Please let me know if you have any additional questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![adhamdoody7813](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adhamdoody7813/32/45544_2.png) [@adhamdoody7813](https://community.auth0.com/u/adhamdoody7813)\
**Post date:** [May 31, 2023, 7:22pm UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/6 "2023-05-31T19:22:56Z")

</div>

@rueben.tiow i can’t find the config.ts file u mentioned the only file that i have is next.config.js

---

<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:** [June 1, 2023, 1:26am UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/7 "2023-06-01T01:26:14Z")

</div>

Hi @adhamdoody7813,

Thank you for your reply.

If you are using the [Auth0 Next.js Quickstart](https://auth0.com/docs/quickstart/webapp/nextjs/interactive), there should be a `.env` file in which you can set the `AUTH0_BASE_URL` value.

With that, could you please confirm if you have a chance to locate this file and include the redirect URL in the `AUTH_BASE_URL` value?

For example,t his is what I see in my file:

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

I look forward to your update.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![adhamdoody7813](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adhamdoody7813/32/45544_2.png) [@adhamdoody7813](https://community.auth0.com/u/adhamdoody7813)\
**Post date:** [June 1, 2023, 6:42am UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/8 "2023-06-01T06:42:25Z")

</div>

@rueben.tiow i do have the .env file

---

<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:** [June 5, 2023, 11:56pm UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/9 "2023-06-05T23:56:45Z")

</div>

Hi @adhamdoody7813,

Thank you for that information.

Have you gotten a chance to update the .env file’s `AUTH0_BASE_URL`?

See this link as a reference: [auth0-nextjs-samples/Sample-01 at main · auth0-samples/auth0-nextjs-samples · GitHub](https://github.com/auth0-samples/auth0-nextjs-samples/tree/main/Sample-01#configure-credentials)

---

<div class="post-metadata">

**Author:** ![adhamdoody7813](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adhamdoody7813/32/45544_2.png) [@adhamdoody7813](https://community.auth0.com/u/adhamdoody7813)\
**Post date:** [June 7, 2023, 2:19am UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/10 "2023-06-07T02:19:30Z")

</div>

@rueben.tiow i have attempted to set the auth\_0\_BASE\_URL with the url that i want the user to be redirected to after he logs in `http:localhost:3000/PostsPage` if that’s correct however when i click the login button which redirects me to the universal login page i get this

 ![2023-06-07 04-09-57](https://global.discourse-cdn.com/auth0/original/3X/4/9/491c4bc18cd98a1ae4e46cb9f53547290b6f2aa1.png) , i have updated my allowed callback urls as well

---

<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:** [June 16, 2023, 1:24am UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/11 "2023-06-16T01:24:52Z")

</div>

Hi @adhamdoody7813.

Thank you for the update.

I noticed in your screenshot an error where it states that there is a Callback URL mismatch.

Beneath the page, there is a **Technical Details** section. If you click on the link to “see details for this error” it should provide more information about the actual and expected callback URL. Afterwards, you can check your Application settings to verify if it has the callback URL.

Please let me know how it goes.

Thanks,  
Rueben.

---

<div class="post-metadata">

**Author:** ![adhamdoody7813](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adhamdoody7813/32/45544_2.png) [@adhamdoody7813](https://community.auth0.com/u/adhamdoody7813)\
**Post date:** [June 17, 2023, 3:51pm UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/12 "2023-06-17T15:51:01Z")

</div>

@rueben.tiow i have actually check my callback field i do have the right callbacks but for some reason i got this message

---

<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:** [July 1, 2023, 3:51pm UTC](https://community.auth0.com/t/how-do-i-redirect-users-to-a-page-in-my-app-after-login-using-universal-login-with-next-js/107199/13 "2023-07-01T15:51:03Z")

</div>

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