/
Contact usSee pricingStart building
    Overview
    Changelog
    Installation

    Pre-built UI

    StytchB2B
      Configuration
      Callbacks
    Admin Portal
      SSO
      Org Settings
      Member Management
      SCIM
    B2BIdentityProviderBeta
      Configuration
      UI Callbacks

    Headless

    Organizations
      Get Organization
      Get Organization by Slug
      Update Organization
      Delete Organization
    Members
      Get Member
      Create Member
      Update Member
      Search Members
      Delete Member
      Reactivate Member
      Delete Member Password
      Delete Member MFA Phone Number
      Delete Member MFA TOTP
      Unlink Retired Member Email
      Update Self
      Delete Self Password
      Delete Self MFA Phone Number
      Delete Self MFA TOTP
      Unlink Retired Self Email
      Update Member (Deprecated)
      Delete Member MFA Phone Number (Deprecated)
    RBAC
      Is Authorized
      Permissions
    Email Magic Links
      Login or Signup
      Invite
      Authenticate
      Send Discovery Email
      Authenticate Discovery Magic Link
    Email One-time Passcodes (OTPs)
      Login or Signup
      Authenticate OTP
      Send Discovery Email OTP
      Authenticate Discovery Email OTP
    OAuth
      Start OAuth Flow
      Google One Tap
      Authenticate
      Start Discovery OAuth Flow
      Discovery Authenticate
    Session Management
      Get Session
      Authenticate Session
      Revoke Session
      Update Session
      Exchange Session
      Get Tokens
      Revoke Sessions for Member
    SSO
      Start SSO Flow
      Authenticate
      Get SSO Connections
      Discover SSO Connections
      Delete SSO Connection
      Create SAML Connection
      Update SAML Connection
      Update SAML Connection by Metadata URL
      Delete Verification Certificate
      Create OIDC Connection
      Update OIDC Connection
      Create External Connection
      Update External Connection
    Discovery
      List Discovered Organizations
      Create Organization via Discovery
      Exchange Intermediate Session
    Passwords
      Authenticate
      Reset by Email Start
      Reset by Email
      Reset by Existing Password
      Reset by Session
      Strength Check
    • Discovery

      • Authenticate
        Reset by Email Start
        Reset by Email
    SCIM
      Create SCIM Connection
      Update SCIM Connection
      Delete SCIM Connection
      Get SCIM Connection
      SCIM Token Rotation Start
      SCIM Token Rotation Complete
      SCIM Token Rotation Cancel
      Get SCIM Connection Groups
    Multi-Factor Authentication
    • One-Time Passcodes

      • SMS Send
        SMS Authenticate
    • Time-Based One-Time Passcodes

      • TOTP Create
        TOTP Authenticate
    • Recovery Codes

      • Recovery Codes Recover
        Rotate Recovery Codes
        Get Recovery Codes
    Impersonation
      Authenticate

    More Resources

    Cookies & session management
    SWR & caching
    TypeScript
Get support on SlackVisit our developer forum

Contact us

B2B Saas Authentication

/

Frontend SDKs

/

Installation

Installation

React

For a full walk-through of how to get up and running with a sign-up and login flow using Stytch, check out our React Quickstart Guide.

1
Install Packages

To use the React FE SDK, you need to install both the @stytch/react and @stytch/vanilla-js packages:

npm install @stytch/react @stytch/vanilla-js --save

2
Create the Stytch client

First, initialize the Stytch UI client, passing in your Project's public_token from the Stytch dashboard.

import { createStytchB2BUIClient } from '@stytch/react/b2b/ui';

const stytch = createStytchB2BUIClient(
  import.meta.env.STYTCH_PUBLIC_TOKEN, // or process.env.STYTCH_PUBLIC_TOKEN for non-Vite based projects
);

If you do not want to use the pre-built UI components, you can instead initialize the headless client:

import { createStytchB2BHeadlessClient } from '@stytch/react/b2b/headless';

const stytch = createStytchB2BHeadlessClient(
  import.meta.env.STYTCH_PUBLIC_TOKEN, // or process.env.STYTCH_PUBLIC_TOKEN for non-Vite based projects
);

3
Wrap your application in <StytchB2BProvider>

Next, pass the Stytch client to the StytchB2BProvider component at the root of your application, making it accessible to all child components.

import { StytchB2BProvider } from '@stytch/react/b2b';
import { createStytchB2BUIClient } from '@stytch/react/b2b/ui';

const stytch = createStytchB2BUIClient(
  import.meta.env.STYTCH_PUBLIC_TOKEN, // or process.env.STYTCH_PUBLIC_TOKEN for non-Vite based projects
);

const root = ReactDOM.createRoot(document.getElementById("root")!);

root.render(
  <React.StrictMode>
    <StytchB2BProvider stytch={stytch}>
      <Router>
        <App />
      </Router>
    </StytchB2BProvider>
  </React.StrictMode>
);

4
Add your login flow

You have now initialized the Stytch client, and can add the <StytchB2B> pre-built login component to get a robust, end-to-end login flow working with just a simple config.

Next.js

For a full walk-through of how to get up and running with a sign-up and login flow using Stytch, check out our Next.js Quickstart Guide.

1
Install Packages

To use the Next.js FE SDK, you need to install both the @stytch/nextjs and @stytch/vanilla-js packages:

npm install @stytch/nextjs @stytch/vanilla-js --save

2
Create the Stytch client

First, initialize the Stytch UI client, passing in your Project's public_token from the Stytch dashboard.

import { createStytchB2BUIClient } from '@stytch/nextjs/b2b/ui';

const stytch = createStytchB2BUIClient(
  process.env.NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN,
);

If you do not want to use the pre-built UI components, you can instead initialize the headless client:

import { createStytchB2BHeadlessClient } from '@stytch/nextjs/b2b/headless';

const stytch = createStytchB2BHeadlessClient(
  process.env.NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN,
);

3
Wrap your application in <StytchB2BProvider>

Next, pass the Stytch client to the StytchB2BProvider component at the root of your application, making it accessible to all child components.

import { StytchB2BProvider } from '@stytch/nextjs/b2b';
import { createStytchB2BUIClient } from '@stytch/nextjs/b2b/ui';

const stytch = createStytchB2BUIClient(
  process.env.NEXT_PUBLIC_STYTCH_PUBLIC_TOKEN,
);

export default function MyApp({ Component, pageProps }: AppProps) {
  return (
    <>
      <Head>
         // Truncated
      </Head>

      <StytchB2BProvider stytch={stytchClient}>
        <main>
          <div className="container">
            <Component {...pageProps} />
          </div>
        </main>
      </StytchB2BProvider>
    </>
  );
}

4
Add your login flow

You have now initialized the Stytch client, and can add the <StytchB2B> pre-built login component to get a robust, end-to-end login flow working with just a simple config.

React

1.

Install Packages

2.

Create the Stytch client

3.

Wrap your application in <StytchB2BProvider>

4.

Add your login flow

Next.js

1.

Install Packages

2.

Create the Stytch client

3.

Wrap your application in <StytchB2BProvider>

4.

Add your login flow