As of 07/2025 it seems that there was a huge revision to the auth0 nextjs SDK. I cant find where in the examples it displays how to pass connection
and organization
parameters to bypass the selection screen.
How would you do this in the new paradigm with the new auth handler?
Here is the old way to do it using the login handler:
const loginOptions = {
authorizationParams: {
prompt: 'login',
// Conditionally add organization and connection parameters
// These will only be added if an organizationId was successfully found it has a connection value.
...(organizationId ? { organization: organizationId } : {}),
...(organizationId && connectionValue
? { connection: connectionValue }
: {}),
},
returnTo: '/api/auth/postlogin', // Your existing returnTo path
};
return handleLogin(request, res, loginOptions);
Its not clear to me how to do this with the handler endpoint missing? Would i move this logic to middleware? We rely on query params.
Hi @arahman,
Welcome to the Auth0 Community!
The /api/auth/login
is not missing, but the routing is done automatically with the newest version of the NextJS SDK, so in the V4 version you do not have to manually configure a login route handler.
Our V4_MIGRATION_GUIDE specifies that:
In v4, you can simply append the authorization parameters to the query parameter of the login endpoint and they will be automatically fowarded to the /authorize
endpoint, like so:
<a href="/auth/login?audience=urn:my-api">Login</a>
Or alternatively, it can be statically configured when initializing the SDK, like so:
export const auth0 = new Auth0Client({
authorizationParameters: {
scope: "openid profile email",
audience: "urn:custom:api",
ext-param: "value" // such as connection or organization
},
})
This information is also detailed on the EXAMPLES.md page of the SDK, particularly about the returnTo parameter as well.
This Knowledge Article should help as well - Pass Additional Parameter to the Universal Login URL.
I hope this helps.
Thanks,
Remus
Hi Remus,
Thank you for responding!
So if i wanted to pass on organization
and connection
parameters i could do so like this?
<a href="/auth/login?organization=auth0orgId&connection=auth0connectionId">Login</a>
This is to bypass this screen for my users:
Thanks!
Hi @arahman,
The added query parameters to the URL mentioned above look correct to me, so indeed by passing the organization to the /authorize
your users should be prompted to enter their organization first.
If you have other questions please let me know.
Thanks,
Remus