Setting user metadata from with React SPA

I am trying to build a service that has two types of users - I want to set their roles depending upon which button they click (sign up as A vs. sign up as B) using the react-auth0-spa library.

I don’t see any sort of parameters that can go into loginWithRedirect where I can specify what kind of role they want - is there a recommended way to do this?

Hi Ericxgao, and welcome to the Auth0 community! :tada:

You can pass in any custom parameter to loginWithRedirect you want and this will be available from within the rules. You can then use the rules to specify their role.

For example, if you do:

loginWithRedirect(uri: ‘localhost:3000’, custom_param: ‘role’)

The rule context will contain this custom_param within the query object, and you can then implement some logic to associate the user with that role similar to what is here: