Examples and considerations when using the headless SDKs to build your own custom auth.
// Start the authentication flow import { useStytchB2BClient, useStytchMember, useStytchMemberSession } from '@stytch/nextjs/b2b'; const Login = (organization) => { const stytchB2BClient = useStytchB2BClient(); const sendEmailMagicLink = async () => { await stytchB2BClient.magicLinks.email.loginOrSignup({ email_address: 'sandbox@stytch.com', organization_id: organization.organization_id }); }; return <button onClick={sendEmailMagicLink}>Login</button>; //...
// Complete the authentication flow const Authenticate = () => { const stytchB2BClient = useStytchB2BClient(); const router = useRouter(); useEffect(() => { const token = router?.query?.token?.toString(); stytchB2BClient.magicLinks.authenticate({ magic_links_token: token, session_duration_minutes: 60, }); }, [router, stytchB2BClient]); //...