I am trying to use Stytch with the B2B environment in NextJS 14 and the App router. I wrap the application in the StytchB2BProvider. When I try to use the useStitchUser in a client component, I am told that I need to use StitchProvider. Are there any examples of using B2B with NextJS and the App Router? I was unable to find anything in the docs.
Thanks.
Hey Steve,
Thanks for posting!
When I try to use the useStitchUser in a client component, I am told that I need to use StitchProvider
The equivalent of the useStytchUser()
hook in our B2B API is useStytchMember()
(documentation can be found here!). Would you mind trying swapping out instances useStytchUser()
for useStytchMember()
?
Are there any examples of using B2B with NextJS and the App Router? I was unable to find anything in the docs.
We don’t have any examples of using our NextJS SDK with App Router in a B2B context specifically, but we do have some related resources that might help, which I’ll list below! In general, you’ll just need to wrap your application in <StytchB2BProvider>
within layout.tsx
for the App Router. I’ll also note that we’re actively working on some NextJS documentation that’s specific to B2B!
Both of the above examples are with our Consumer API, but many of the NextJS-specific principles will still apply at a high level within a B2B context.
Happy to help with any other questions about this that might come up as well!