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
toStytchB2BProvider
andStytchUIClient
toStytchB2BUIClient
. - In components/TokenAuthenticator.js I changed
useStytch
touseStytchB2BClient
.
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.