Passing initialScreen to Lock from auth0-spa-js

Turns out it was super easy - I can pass any extra parameters to loginWithRedirect and they will end up on the authorize URL string as url-encoded parameters.

loginWithRedirect({ mode: 'signUp' });

…and in the custom login page:

// retrieve screen mode from extra params if sent; default to 'login'
var mode = config.extraParams.mode || 'login';
...
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
  auth: {
 // ...
  },
  // add a selector for which screen to put up 
  initialScreen: mode,
});

I had a logic error in my first attempt :wink:

3 Likes