# Trouble with custom signup and automatic login flow in Next.js with Auth0

**URL:** <https://community.auth0.com/t/trouble-with-custom-signup-and-automatic-login-flow-in-next-js-with-auth0/189388>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [July 18, 2025, 8:49pm UTC](https://community.auth0.com/t/trouble-with-custom-signup-and-automatic-login-flow-in-next-js-with-auth0/189388 "2025-07-18T20:49:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zeitten](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zeitten/32/70868_2.png) [@Zeitten](https://community.auth0.com/u/Zeitten)\
**Post date:** [July 18, 2025, 8:49pm UTC](https://community.auth0.com/t/trouble-with-custom-signup-and-automatic-login-flow-in-next-js-with-auth0/189388/1 "2025-07-18T20:49:03Z")

</div>

Hi everyone,

We’re working on a Next.js application using @auth0/nextjs-auth0 v3.5.0, and we’re running into some issues with our custom login/signup flow.

Here’s the setup:  
• We’re using the custom login page template with some changes to match our UI requirements.  
• We have a Post User Registration Action that performs some operations in our backend.  
• In the HTML template, we’re already using webAuth.login and webAuth.signupAndLogin.

What we’re trying to do is customize the signup flow: instead of using signupAndLogin, we perform just the signup, and after a successful response, we wait 3 seconds (using setTimeout) to give the Action time to complete. Then, we attempt to trigger login automatically.

However, this flow is not working as expected. It behaves strangely: the user is signed up, the login seems to happen, but then they’re unexpectedly redirected back to the login page — as if the login didn’t persist or was ignored.

As shown in the attached screenshot, right after the /resume step, there’s a redirect to a strange URL, which appears to be the root of my Next.js app. Interestingly, when I log in directly with an existing user (without going through the signup flow), everything works perfectly, and the user is redirected to the correct callback URL (/api/auth/callback).

None of this behavior makes sense to us. We’d really appreciate any help to understand what’s going wrong and how we can properly implement this flow.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Zeitten](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zeitten/32/70868_2.png) [@Zeitten](https://community.auth0.com/u/Zeitten)\
**Post date:** [July 18, 2025, 9:00pm UTC](https://community.auth0.com/t/trouble-with-custom-signup-and-automatic-login-flow-in-next-js-with-auth0/189388/2 "2025-07-18T21:00:05Z")

</div>

It seems that I can’t attach a screenshot here:

```auto
An error occurred: Sorry, you can't embed media items in a post.

```
