Nextjs add dinamicly authorizationParams

I am migrating an application made in Angular to Nextjs 14.

I have already integrated it with Auth0, and it works well.

In my Angular app, if the URL is http:localhost:3000, I log in with the default configuration, but if the URL has an extra parameter, for example: http:localhost:3000/callback?connection=any-connection, I need to log in by adding the connection from the URL to authorizationParams.

Here is my code in angular:

 private checkConnection(): boolean {
    const connection =
      this.activeRoute.snapshot.queryParamMap.get('connection');

    if (connection) {
      this.auth.loginWithRedirect({
        authorizationParams: {
          connection,
        },
      });
      return true;
    }

    return false;
  }

My question is: how can I achieve this same behavior in Nextjs?

Thank you very much for your help.

Hi @pabrodriguez,

Welcome back to the Auth0 Community !

Answering this since it might helps others as well.
In the latest version of NextJs it is specified that the useSearchParams helps you read the current URL’s query string, so this way you can get the connection parameter.

Then custom routes can be configured by checking the custom routes docs from our Auth0 SDK.

Hope this helps.
Thanks,
Remus

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