Problems converting stytch-react-example for a B2B installation

I’m new to Stytch. Our React site is using B2B instead of consumer. As a starter I took the stytch-react-example project and ran it. It ran fine, but is set up for consumer auth. As I like the TokenAuthenticator part of it, I tried to just convert it to use B2B calls instead, and it failed. I was hoping to get some idea of whether this is a Stytch bug or I’m just doing something stupid. My changes:

  • In index.js, I changed StytchProvider to StytchB2BProvider and StytchUIClient to StytchB2BUIClient.
  • In components/TokenAuthenticator.js I changed useStytch to useStytchB2BClient.

The problem is, the first line in TokenAuthenticator says:

const stytch = useStytchB2BClient();

and this throws the error:
useStytchB2BClient can only be used inside
at invariant (http://localhost:3000/static/js/bundle.js:1128:20)
at useStytchB2BClient (http://localhost:3000/static/js/bundle.js:1202:3)
at TokenAuthenticator (http://localhost:3000/static/js/bundle.js:400:92)

The invariant is that the Stytch code in invariant is looking for ctx.isMounted = true. In the consumer case this is true. In the B2B case, the code is different and it’s not, it’s false.

Is there some way I can fix things to get this to work? Given the StytchB2BProvider and StytchB2BUIClient, I’m not sure what else to do.

I left out one crucial symbol in my stack trace. The first line should read:

useStytchB2BClient can only be used inside StytchB2BProvider.

The thing is, here’s the code in index.js as of now:

const root = ReactDOM.createRoot(document.getElementById(‘root’));

root.render(

<React.StrictMode>

{/* StytchProvider gives our app access to the Stytch client */}

</React.StrictMode>

);

Hey Dave,

Thanks for reaching out! We see you also reached out in our Community Slack and we have responded there, so we’ll close this thread out to consolidate communications in Slack!

Cheers,
Matt
Stytch Support

Thanks Matt! I saw the notification on Slack, so am working from there. BTW, is that the recommended way of interacting with Support, or do you prefer we go through email?

Cheers,

Dave

Hey Dave,

It’s totally up to you – whatever you prefer! We actively monitor both email and Slack. If you have a sensitive request that you’d prefer not to ask publicly, then email is the way to go – but otherwise, feel free to use whatever method is most convenient for you.

Hope you have a great afternoon!

Best,
Nicole
Stytch Support