Nextjs How to get signup to return to a different page to signin

Hi,
When a new user signs up, I would like to direct them to an update profile page but an existing user to simply be directed to the home page.
in me auth/[auth0]/route.ts file I have the below:

import { handleAuth, handleLogin } from '@auth0/nextjs-auth0';

export const GET = handleAuth({
	login: handleLogin({
		returnTo: '/',
	}),
	signup: handleLogin({
		authorizationParams: {
			screen_hint: 'signup',
		},
		returnTo: '/signup',
	}),
});

Is there a way to allow a user to enter a name in addition to their email address?

Hi @rationem,

I recommend using a post-login action to redirect new users to an update profile page. Note that new users are automatically logged in after signing up. Because of this design, we can use a post-login action to redirect only new users by checking their login count.

For example:

exports.onExecutePostLogin = async (event, api) => {
  if(event.stats.logins_count === 1){
    api.redirect.sendUserTo("https://someexample.com")
  }
};

Let us know if you have any questions.

Thanks,
Rueben

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