> ## Documentation Index
> Fetch the complete documentation index at: https://stytch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Stytch Login

> Implement the Stytch Login component using the Stytch React Native SDK

The React Native SDK provides the option for you to use pre-built login flows, supporting dark and light themes, with easy configuration, detailed below.

## Handling Deeplinks

For Email Magic Links, OAuth, SSO, and Password Reset flows, this component handles the deeplinking automatically. You'll need to add a custom URL scheme and redirect URL as explained below.

First, you need to configure your app to listen for a deeplink with the scheme: `stytch-ui-[YOUR_PUBLIC_TOKEN]`. How you do that will depend on your supported platforms and whether you are using [bare React Native](https://reactnative.dev/docs/linking) or [Expo](https://docs.expo.dev/guides/linking/#linking-to-your-app).

<Note>
  If you are using [Expo Router](https://docs.expo.dev/versions/latest/sdk/router/), which is the default for new apps created with create-expo-app, you must add a `+native-intent.tsx` file which ignores the incoming Stytch UI deep links. An example of this can be found [here](https://github.com/stytchauth/stytch-react-native-ui-expo-router/blob/main/app/%2Bnative-intent.tsx).
</Note>

Lastly, you'll need to add a special redirect URL in your Stytch Dashboard [Redirect URLs](https://stytch.com/dashboard/redirect-urls). It should have a URL of `stytch-ui-[YOUR_PUBLIC_TOKEN]://deeplink` and be applied to all redirect types.

Once both the scheme (in your app) and the redirect URL (in your Dashboard) are configured, our pre-built UI should handle the rest.

## Props

<ParamField path="client" type="StytchB2BClient" required>
  The Stytch B2B client object.
</ParamField>

<ParamField path="config" type="StytchRNB2BUIConfig" required>
  The config object for the UI components.

  <ParamField path="config.productConfig" type="StytchB2BUIConfig" required>
    The config object for the UI components.

    <Expandable title="properties">
      <ParamField path="products" type="B2BProducts[]" required>
        The products array allows you to specify the authentication methods that you would like to expose to your users.

        The order of the products that you include here will also be the order in which they appear in the login form, with the first product specified appearing at the top of the login form.

        Currently the SDK supports our `emailMagicLinks`, `oauth`, `sso`, and `passwords` products.

        `emailMagicLinks` and `oauth` are supported in both authentication flow types, whereas `sso` is only supported in the Organization authentication flow type. `passwords` is always supported in the Organization authentication flow type, but is also supported in the Discovery flow if cross-org passwords are enabled for the project.

        If the only product specified is `oauth`, and the only OAuth provider specified is google with `one_tap` set to true, the login form will not be displayed. Instead, we will only show the Google One Tap prompt in the upper right of the user's browser.
      </ParamField>

      <ParamField path="authFlowType" type="AuthFlowType" required>
        The authFlowType lets you specify the authentication flow type that you wish to enable in the SDK. The options are `Discovery` to let Members log into any Organization they are a part of; `Organization` to let Members log into a specific Organization; and `PasswordReset` to handle password reset flows (after the user clicks the password reset redirect URL). To enable the Organization flow type, you also must add a slug pattern to the authorized domain through the Frontend SDK page in the Dashboard.
      </ParamField>

      <ParamField path="sessionOptions" type="SessionOptions">
        The options for session management. We create a session for Members when they log in. You can access a Member or session using the Member or Session SDK methods.

        <Expandable title="properties">
          <ParamField path="sessionDurationMinutes" type="integer">
            Set the session lifetime to be this many minutes from now; minimum of 5 and a maximum of 525600 minutes (365 days). Note that a successful authentication will continue to extend the session this many minutes.
          </ParamField>
        </Expandable>
      </ParamField>

      <ParamField path="emailMagicLinksOptions" type="RNUIEmailMagicLinksOptions">
        The options for email magic links. This is required if `emailMagicLinks` is present in the products array.

        <Expandable title="properties">
          <ParamField path="loginTemplateId" type="string">
            Custom template ID for login emails. By default, it will use your default email template. Templates can be added in the [Stytch dashboard](https://stytch.com/dashboard/templates) using our built-in customization options or custom HTML templates with type “Magic links - Login”.
          </ParamField>

          <ParamField path="signupTemplateId" type="string">
            Custom template ID for sign-up emails. By default, it will use your default email template. Templates can be added in the [Stytch dashboard](https://stytch.com/dashboard/templates) using our built-in customization options or custom HTML templates with type “Magic links - Sign-up”.
          </ParamField>
        </Expandable>
      </ParamField>

      <ParamField path="passwordOptions" type="object">
        The options for Passwords. This is required if `passwords` is present in the products array.

        <Expandable title="properties">
          <ParamField path="resetPasswordExpirationMinutes" type="integer">
            The number of minutes that the password reset token sent in password reset emails will be valid for. Defaults to 30 minutes.
          </ParamField>

          <ParamField path="resetPasswordTemplateId" type="string">
            Custom template ID for password reset emails, configured via [the Branding page](https://stytch.com/dashboard/templates) in the Stytch Dashboard. If this value is not specified, your default password reset template will be used.
          </ParamField>
        </Expandable>
      </ParamField>

      <ParamField path="oauthOptions" type="B2BOAuthOptions" required>
        The options for OAuth. This is required if `oauth` is present in the products array.

        <Expandable title="properties">
          <ParamField path="providers" type="B2BOAuthProviderConfig[]" required>
            Specifies which OAuth providers to display.

            <Expandable title="properties">
              <ParamField path="type" type="string" required>
                The provider type. Currently we support `google`, `microsoft`, `hubspot`, `slack`, and `github`.
              </ParamField>

              <ParamField path="customScopes" type="array[string]">
                An optional array of scopes that Stytch will request for your application in addition to the base set of scopes required for login.
              </ParamField>

              <ParamField path="providerParams" type="object">
                An object with any additional parameters that you'd like to pass along to the OAuth provider (for example, `login_hint`, for providers that support it).
              </ParamField>
            </Expandable>
          </ParamField>

          <ParamField path="directLoginForSingleMembership" type="object">
            A configuration option that allows you to skip the discovery flow and log a Member in directly only if they are a Member of a single Organization.

            <Expandable title="properties">
              <ParamField path="status" type="boolean">
                Whether or not direct login for single membership is enabled. If the user has an invite or can JIT provision into an Organization the Discovery Organization select pane will still be shown unless the other two properties are also enabled.
              </ParamField>

              <ParamField path="ignoreInvites" type="boolean">
                If enabled, logs a user directly into their existing Organization even if they have one or more pending invites to a different Organization. This bypasses the Discovery Organization select pane.
              </ParamField>

              <ParamField path="ignoreJitProvisioning" type="boolean">
                If enabled, logs a user directly into their existing Organization even if they have Organizations they could join via JIT provisioning. This bypasses the Discovery Organization select pane.
              </ParamField>
            </Expandable>
          </ParamField>

          <ParamField path="directCreateOrganizationForNoMembership" type="boolean">
            Whether or not an Organization should be created directly when a user has no memberships, invitations, or Organizations they could join via JIT provisioning. This has no effect if the ability to create Organizations from the frontend SDK is disabled in the Stytch Dashboard. Defaults to false.
          </ParamField>

          <ParamField path="disableCreateOrganization" type="boolean">
            Whether to prevent users who are not Members of any Organization from creating a new Organization during the discovery flow. This has no effect if the ability to create Organizations from the frontend SDK is disabled in the Stytch Dashboard. Defaults to false.
          </ParamField>
        </Expandable>
      </ParamField>

      <ParamField path="mfaProductOrder" type="array">
        The order to present MFA products to a Member when multiple choices are available, such as during enrollment.

        Currently the SDK supports our `smsOtp` and `totp` MFA products.
      </ParamField>

      <ParamField path="mfaProductInclude" type="array">
        MFA products to include in the UI. If specified, the list of available products will be limited to those included. Defaults to all available products.

        Note that if an Organization restricts the available MFA methods, the Organization's settings will take precedence. In addition, if a Member is enrolled in MFA compatible with their Organization's policies, their enrolled methods will always be made available.

        Currently the SDK supports our `smsOtp` and `totp` MFA products.
      </ParamField>

      <ParamField path="organizationSlug" type="string">
        The slug of the Organization to present login options for. This is only used when the config.authFlowType is `AuthFlowType.Organization`.
      </ParamField>
    </Expandable>
  </ParamField>

  <ParamField path="config.styles" type="StytchStyles">
    An object that configures the dark and light themes used by the login UI.

    <Expandable title="properties">
      <ParamField path="darkTheme" type="StytchTheme">
        Styles that will be applied on devices in dark mode.

        <Expandable title="properties">
          <ParamField path="backgroundColor" type="string" />

          <ParamField path="primaryTextColor" type="string" />

          <ParamField path="secondaryTextColor" type="string" />

          <ParamField path="disabledTextColor" type="string" />

          <ParamField path="successColor" type="string" />

          <ParamField path="errorColor" type="string" />

          <ParamField path="socialButtonBackgroundColor" type="string" />

          <ParamField path="socialButtonTextColor" type="string" />

          <ParamField path="buttonBackgroundColor" type="string" />

          <ParamField path="buttonTextColor" type="string" />

          <ParamField path="buttonBorderColor" type="string" />

          <ParamField path="buttonBorderRadius" type="number" />

          <ParamField path="disabledButtonBackgroundColor" type="string" />

          <ParamField path="disabledButtonBorderColor" type="string" />

          <ParamField path="disabledButtonTextColor" type="string" />

          <ParamField path="inputBorderRadius" type="number" />

          <ParamField path="inputBorderColor" type="string" />

          <ParamField path="inputBackgroundColor" type="string" />

          <ParamField path="inputTextColor" type="string" />

          <ParamField path="inputPlaceholderTextColor" type="string" />

          <ParamField path="disabledInputBorderColor" type="string" />

          <ParamField path="disabledInputBackgroundColor" type="string" />

          <ParamField path="disabledInputTextColor" type="string" />

          <ParamField path="dialogTextColor" type="string" />

          <ParamField path="hideHeaderText" type="boolean" />

          <ParamField path="warningBackgroundColor" type="string" />

          <ParamField path="warningTextColor" type="string" />
        </Expandable>
      </ParamField>

      <ParamField path="lightTheme" type="StytchTheme">
        Styles that will be applied on devices in light mode.

        <Expandable title="properties">
          <ParamField path="backgroundColor" type="string" />

          <ParamField path="primaryTextColor" type="string" />

          <ParamField path="secondaryTextColor" type="string" />

          <ParamField path="disabledTextColor" type="string" />

          <ParamField path="successColor" type="string" />

          <ParamField path="errorColor" type="string" />

          <ParamField path="socialButtonBackgroundColor" type="string" />

          <ParamField path="socialButtonTextColor" type="string" />

          <ParamField path="buttonBackgroundColor" type="string" />

          <ParamField path="buttonTextColor" type="string" />

          <ParamField path="buttonBorderColor" type="string" />

          <ParamField path="buttonBorderRadius" type="number" />

          <ParamField path="disabledButtonBackgroundColor" type="string" />

          <ParamField path="disabledButtonBorderColor" type="string" />

          <ParamField path="disabledButtonTextColor" type="string" />

          <ParamField path="inputBorderRadius" type="number" />

          <ParamField path="inputBorderColor" type="string" />

          <ParamField path="inputBackgroundColor" type="string" />

          <ParamField path="inputTextColor" type="string" />

          <ParamField path="inputPlaceholderTextColor" type="string" />

          <ParamField path="disabledInputBorderColor" type="string" />

          <ParamField path="disabledInputBackgroundColor" type="string" />

          <ParamField path="disabledInputTextColor" type="string" />

          <ParamField path="dialogTextColor" type="string" />

          <ParamField path="hideHeaderText" type="boolean" />

          <ParamField path="warningBackgroundColor" type="string" />

          <ParamField path="warningTextColor" type="string" />
        </Expandable>
      </ParamField>
    </Expandable>
  </ParamField>
</ParamField>

<ParamField path="callbacks" type="object">
  Optional callbacks that are triggered by various events in the SDK. See more details about the callbacks [here](/docs/api-reference/b2b/mobile-sdks/react-native/prebuilt-ui/callbacks).

  <Expandable title="properties">
    <ParamField path="onEvent" type="(data) => void">
      A callback function that responds to events sent from the SDK.
    </ParamField>

    <ParamField path="onError" type="(data) => void">
      A callback function that responds to errors in the SDK. It is useful for debugging during development and error handling in production.
    </ParamField>
  </Expandable>
</ParamField>

<Panel>
  <RequestExample>
    ```jsx theme={null}
    import {
      StytchB2BUI,
      StytchRNB2BUIConfig,
      AuthFlowType,
      B2BProducts,
      B2BOAuthProviders,
      Callbacks,
      StytchEventType,
    } from '@stytch/react-native';
    import { useStytchB2BClient } from '@stytch/react-native/b2b';

    const Login = ({ navigation }) => {
      const stytch = useStytchB2BClient();
      const callbacks: Callbacks = {
        onEvent(event) {
          if (event.type == StytchEventType.AuthenticateFlowComplete) {
            navigation.navigate('Profile');
          }
        },
      };

      const config: StytchRNB2BUIConfig = {
        productConfig: {
          products: [B2BProducts.emailMagicLinks, B2BProducts.oauth, B2BProducts.passwords, B2BProducts.sso],
          authFlowType: AuthFlowType.Organization,
          sessionOptions: { sessionDurationMinutes: 60 },
          oauthOptions: {
            providers: [B2BOAuthProviders.Google],
          },
        },
        organizationSlug: 'your-organization-slug',
      };

      return <StytchB2BUI client={stytch} config={config} callbacks={callbacks}></StytchB2BUI>;
    };

    export default Login;
    ```
  </RequestExample>
</Panel>
