Skip to main content
import { useStytchB2BClient } from '@stytch/nextjs/b2b';

export const MyComponent = () => {
  const stytch = useStytchB2BClient();

  const handleAction = async () => {
    // Use the client to call SDK methods
    await stytch.session.authenticate({
      session_duration_minutes: 60,
    });
  };

  return <button onClick={handleAction}>Authenticate</button>;
};
useStytchB2BClient is a hook that returns the Stytch client that was passed into <StytchB2BProvider>. Use the client to call any SDK methods. To follow React best practices, these methods should only be called in callbacks or useEffect hooks.