# How to pass additional parameters as object from react js(Client) to Auth0 Universal Login page

**URL:** <https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182>\
**Category:** Get Help\
**Tags:** signup, universal-login\
**Created:** [March 27, 2021, 6:16pm UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182 "2021-03-27T18:16:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vora.da](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vora.da/32/17395_2.png) [@vora.da](https://community.auth0.com/u/vora.da)\
**Post date:** [March 27, 2021, 6:16pm UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182/1 "2021-03-27T18:16:36Z")

</div>

Hey Folks!

I’m using additionalSignUpFields for my custom SignUp page in Auth0 custom Classic Universal Login page. I am trying to pass the object from the client to Classic Universal Login when I redirect to the **My\_Domain\_Name/login**. I want to set the drop-down values which I get from my client(in _select type_ fields in additionalSignUpFields options). I’m not sure how to pass the object with _loginWithRedirect()_ while redirecting to the universal login page.

It would be really great if someone can help me to implement this functionality.

Best,  
Darshana

 ![Universal_Signup](https://global.discourse-cdn.com/auth0/original/3X/e/1/e1c24b52d7eda8520bfed91ecdf5c46631dc08e4.jpeg)

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 29, 2021, 3:18pm UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182/3 "2021-03-29T15:18:38Z")

</div>

Hi @vora.da,

I will do some research on this! Just to make sure I understand the functionality you’d like to implement, do you want to be able to pre-populate the group and/or role fields in your screenshot based on values passed to the `loginWithRedirect` method?

---

<div class="post-metadata">

**Author:** ![vora.da](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vora.da/32/17395_2.png) [@vora.da](https://community.auth0.com/u/vora.da)\
**Post date:** [March 29, 2021, 3:35pm UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182/4 "2021-03-29T15:35:25Z")

</div>

Yes, that is correct! I want to pre-populate the drop-downs by passing the parameters with loginWithRedirect method or by any other possible way. Just to be clear I’m using the custom login page option in the universal login page and for signup fields, I’m using additionalSignUpFields.

additionalSignUpFields: [  
{  
name: “name”,  
placeholder: “enter full name”  
},  
{  
name: “university”,  
placeholder: “university”  
},  
{  
type: “select”,  
name: “group”,  
placeholder: “choose group”,  
options:[  
{value: “na”, label: “N/A”}  
]  
},  
{  
type: “select”,  
name: “role”,  
placeholder: “choose your role”,  
options: [  
{value: “faculty\_pi”, label: “Faculty PI”},  
{value: “student”, label: “Student”},  
]  
},  
{  
name: “phone”,  
placeholder: “enter your phone number”,  
validator: function(phone) {  
return {  
valid: phone.length \>= 10,  
hint: “must have 10 Digits”  
};  
}  
}  
]  
});

So in the above code snippet, I don’t want to hardcode the select option values instead, I want to set the values from the object I pass from the client. Thank you.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 29, 2021, 6:45pm UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182/5 "2021-03-29T18:45:58Z")

</div>

Thank you for clarifying!

What you can do is pass the role and group values in the `config.extraParams` object.

In your application you could pass:

```auto
loginWithRedirect({role: “faculty_pi”})

```

And in the Lock configurations, you could reference the parameters:

```auto
var role = config.extraParams.role;

var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
      // ... other configs
      additionalSignUpFields: [
        {
        type: 'select',
        name: 'role',
        placeholder: 'choose your role',
        prefill: role,
        options: [
          {value: 'faculty_pi', label: 'Faculty PI'},
          {value: 'student', label: 'Student'},
        ]
        }
      ]
    });

```

However, the role value in this example would have to be listed in the field options. You could pre-fill the option you’d like with the `prefill` parameter.

---

<div class="post-metadata">

**Author:** ![vora.da](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vora.da/32/17395_2.png) [@vora.da](https://community.auth0.com/u/vora.da)\
**Post date:** [April 6, 2021, 6:26am UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182/6 "2021-04-06T06:26:37Z")

</div>

Hi Stephanie,

Thank you for your response!

I’m passing loginWithRedirect({role: “faculty\_pi”}) in my application but I’m not getting faculty\_pi option on the signup page. Do you there is any other way I could pass the {role: “faculty\_pi”} object and prefill this option?

What prefill option does is it sets one of the option values which I have already hard coded into my additionalSignUpFields. Basically, it pre-populates the faculty\_pi option for the role when the sign-up page appears.

What I’m trying to do is populate the value I pass with loginWithRedirect. I will not have that option hardcoded in my option to pre-populate it.

Let me know if you need any further clarification.

Thank you.

 ![signup_select_option](https://global.discourse-cdn.com/auth0/original/3X/9/7/97e99a42272c255060fa5c84e8b2a6e57749c0d3.png)

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [April 6, 2021, 6:56pm UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182/7 "2021-04-06T18:56:17Z")

</div>

Oh, I see! Unfortunately, there is not a built-in way to implement dynamic options that are not hard-coded in the configs. You could pass an array of options like this:

```auto
loginWithRedirect({roleOptions: ['faculty_pi', 'student']})

```

and then in the Universal Login template, parse out the option values and labels with something like this:

```auto
    function formatOptionLabel(value) {
      var words = value.split("_");
      return words.map(function (word) { 
          return word[0].toUpperCase() + word.substring(1); 
      }).join(" ");
    }

    var roleOptions = (config.extraParams.roleOptions || '').split(',');
    var roles = roleOptions.map(function(role) {
      var roleLabel = formatOptionLabel(role);
      return {value: role, label: roleLabel}
    });

    // Available Lock configuration options: https://auth0.com/docs/libraries/lock/v11/configuration
    var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
   // ... other configs
      additionalSignUpFields: [
        {
        type: 'select',
        name: 'role',
        placeholder: 'choose your role',
        options: roles
        }
      ]

```

---

<div class="post-metadata">

**Author:** ![vora.da](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vora.da/32/17395_2.png) [@vora.da](https://community.auth0.com/u/vora.da)\
**Post date:** [April 9, 2021, 7:54am UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182/8 "2021-04-09T07:54:01Z")

</div>

Thank you, Stephanie! The above solution works fine.

As I mentioned earlier, I’m not sure how to pass the object with _loginWithRedirect()_ while redirecting to the universal login page. I’m getting undefined in config.extraParams.role. I’m passing these extra paramters from /login endpoint.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [April 9, 2021, 11:24am UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182/9 "2021-04-09T11:24:08Z")

</div>

Glad to hear the solution is working for you!

Regarding `loginWithRedirect`, which SDK are you using in your app? This code is what you’d use for SPAs (auth0-react, auth0-spa-js, etc.) If you are able to pass the params directly, then that works!

---

<div class="post-metadata">

**Author:** ![vora.da](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vora.da/32/17395_2.png) [@vora.da](https://community.auth0.com/u/vora.da)\
**Post date:** [April 9, 2021, 4:25pm UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182/10 "2021-04-09T16:25:31Z")

</div>

Yes, I’m using auth0-react and I’m sending the parameter through loginWithRedirect options.

const LoginButton = () =\> {  
const { loginWithRedirect } = useAuth0();  
return (  
  
\<button className=“login-button” onClick={() =\> loginWithRedirect({role: ‘Student,N/A’})}\> Log In   
  
);  
};

When I’m trying to access _config.extraParams.role_ on the customized Universal Login Lock page, it shows undefined.

---

<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:** [April 24, 2021, 4:26pm UTC](https://community.auth0.com/t/how-to-pass-additional-parameters-as-object-from-react-js-client-to-auth0-universal-login-page/60182/11 "2021-04-24T16:26:00Z")

</div>

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