The config object for the UI components.
UI Configuration
Fields
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 JavaScript SDK supports our emailMagicLinks, oauth, crypto, otp, passkeys and passwords products.
The options for email magic links. This is required if emailMagicLinks is present in the products array.
The URL that will appear in your email template and accepts a token (ex: you implement 'https://example.com/authenticate?token=123' in your app and pass 'https://example.com/authenticate' as the redirect URL). This link should route to an endpoint that authenticates your user via Stytch's authenticate endpoint and redirect to your app's experience for existing users.
Number of minutes the magic link is valid for.
The URL that will appear in your email template and accepts a token (ex: you implement 'https://example.com/authenticate?token=123' in your app and pass 'https://example.com/authenticate' as the redirect URL). This link should route to an endpoint that authenticates your user via Stytch's authenticate endpoint and redirect to your app's experience for new users.
Number of minutes the magic link is valid for.
Custom template ID for login emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for Login.
Custom template ID for sign-up emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for Sign-up.
This flag determines whether the status of a new user will be pending. Users are created with an active status by default. If this flag true, users will be saved with a pending status in Stytch's backend. An example usage of this would be to invite users.
A hint indicating which domain the email will be sent from used in the filters included in the component's links to common email inboxes (for example, https://mail.google.com/mail/u/0/#search/from%3A%40domainHint%20in%3Aanywhere). This field is only required if your project uses more than one custom domain to send emails.
The options for OAuth. This is required if oauth is present in the products array.
An array of OAuth providers you wish to use. Each Provider is an object with a type key that determines the type of provider. The order of the providers in the array determines the order of the rendered buttons.
Each Provider accepts an optional custom_scopes array of scopes that Stytch will request for your application in addition to the base set of scopes required for login.
Each provider also accepts a providerParams 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).
Adds the Google OAuth login button and Google One Tap. If you enable one_tap you may also provide a position parameter. floating is the default and recommended option and will display the One Tap prompt using the browser's native UI (if supported) or in the top right corner of the page (if not). Other position options include:
- floatingOrEmbedded (previously known as embedded): use the browser's native UI (if supported) or embed in the JavaScript SDK login form alongside the other configured sign-in options (if not).
- embeddedOnly: embed in the existing SDK login form if the browser's native UI is not supported, or not at all otherwise. This option is not generally recommended.
- forceLegacyEmbedded: embed in the existing SDK login form even if the browser's native UI is supported. This option is not recommended, will stop being honored by Google in the future, and is only provided for compatibility until then.
You can also provide a cancel_on_tap_outside parameter which controls whether the Google One Tap prompt is automatically dismissed when the user taps outside of it. By default, this is set to true.
If Google OAuth is the only authentication option specified and one_tap is set to floating, the normal Google OAuth login button will not appear in the SDK login form and only the floating One Tap box will be displayed.
Note: If you enable Google One Tap, ensure that you've added your app or website's URL as an authorized JavaScript origin in your Google Developer dashboard. If you're using localhost, make sure to add both http://localhost and http://localhost:port (e.g http://localhost:3000). See Step 5 in your Google OAuth setup guide here.
Note: You will not receive a Google access_token or refresh_token for users who complete the Google One Tap flow, and you will not be able to make Google API calls on their behalf. Accordingly, Google One Tap cannot be used to authorize additional custom scopes. If you need to make calls to Google's APIs to retrieve additional user data, we recommend using standard Google OAuth rather than Google One Tap.
// with One Tap
{ type: 'google', one_tap: true, position: 'floating' | 'floatingOrEmbedded' | 'embeddedOnly' | 'forceLegacyEmbedded' }
// with standard OAuth
{ type: 'google', custom_scopes?: ['...'], providerParams?: {...} }
Adds the Microsoft OAuth start button.
{ type: 'microsoft', custom_scopes?: ['...'], providerParams?: {...} }
Adds the Apple OAuth start button. Apple has no additional scopes that may be requested at this time.
{ type: 'apple' }
Adds the GitHub OAuth start button.
{ type: 'github', custom_scopes?: ['...'], providerParams?: {...} }
Adds the GitLab OAuth start button.
{ type: 'gitlab', custom_scopes?: ['...'], providerParams?: {...} }
Adds the Facebook OAuth start button.
{ type: 'facebook', custom_scopes?: ['...'], providerParams?: {...} }
Adds the Slack OAuth start button.
{ type: 'slack', custom_scopes?: ['...'], providerParams?: {...} }
Adds the Discord OAuth start button.
{ type: 'discord', custom_scopes?: ['...'], providerParams?: {...} }
Adds the Amazon OAuth start button.
{ type: 'amazon', custom_scopes?: ['...'], providerParams?: {...} }
Adds the Bitbucket OAuth start button.
{ type: 'bitbucket', custom_scopes?: ['...'], providerParams?: {...} }
Adds the Coinbase OAuth start button.
{ type: 'coinbase', custom_scopes?: ['...'], providerParams?: {...} }
Adds the LinkedIn OAuth start button.
{ type: 'linkedin', custom_scopes?: ['...'], providerParams?: {...} }
Adds the Twitch OAuth start button.
{ type: 'twitch', custom_scopes?: ['...'], providerParams?: {...} }
Adds the Yahoo OAuth start button.
{ type: 'yahoo', custom_scopes?: ['...'], providerParams?: {...} }
The URL that your users will redirect to after completing the OAuth authentication flow at a given OAuth provider, i.e. after the user returns from authenticating via Google.
This URL should route to an endpoint within your app that will complete the Stytch OAuth authentication flow, by hitting our oauth/authenticate endpoint.
If not specified, the user will be redirected to the default login redirect URL that you've configured in your Dashboard.
The URL that your users will redirect to after completing the OAuth authentication flow at a given OAuth provider, i.e. after the user returns from authenticating via Google.
This URL should route to an endpoint within your app that will complete the Stytch OAuth authentication flow, by hitting our oauth/authenticate endpoint.
If not specified, the user will be redirected to the default sign up redirect URL that you've configured in your Dashboard.
The options for one time passcodes. This is required if otp is present in the products array.
The methods 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. We currently support passcodes on email, sms and whatsapp
Number of minutes the passcode is valid for.
Custom template ID for login emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for Login.
Custom template ID for sign-up emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for Sign-up.
The options for session management. If you are using the otp or crypto product, we also create a session for users when they log in. You can access a user or session using the User or Session SDK methods.
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.
The enableShadowDOM configuration option allows developers to use the Stytch SDK in a shadow DOM. This defaults to false. This property was introduced in v1.0.0 of the @stytch/vanilla-js package. Prior versions of the package default to the shadow DOM being enabled. To retain this behavior, set the flag to true.
The options for passwords. This is required if passwords is present in the products array.
The URL that will appear in your Password Reset email template and accepts a token (ex: you implement 'https://example.com/authenticate?token=123' in your app and pass 'https://example.com/authenticate' as the redirect URL). This link should route to an endpoint that authenticates your user via Stytch's authenticate endpoint and redirect to your app's experience for existing users.
Number of minutes the magic link is valid for.
The redirect URL used in your password reset email template for users who opt to reset their password. This link should route to an page that lets your user reset their password via Stytch's reset password endpoint.
Number of minutes the reset password token is valid for.
Custom template ID for password reset emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for Passwords - Password reset.
The style object allows you to customize the look of the SDK. You can specify some of them or none at all. We'll use our defaults for the ones you don't specify.
The font family that will apply to all text in the SDK.
When this value is true, the title and description text will not show in the SDK.
The configuration object for the Stytch UI container.
The width of the SDK container.
The background color of the SDK container.
The border color of the SDK container.
The border radius of the SDK container.
The configuration object for colors used in the Stytch UI components.
Your primary brand color. This will be applied to most of the text in the SDK.
Your secondary brand color. This will be applied to text disclaimers and other visual elements.
A success color to be used in visual elements.
An error color to be used in visual elements.
The configuration object for buttons in the Stytch UI component.
The configuration object for primary buttons
The text color of the primary button.
The background color of the primary button.
The border color of the primary button.
The border radius of the primary button.
The configuration object for secondary buttons
The text color of the secondary button.
The background color of the secondary button.
The border color of the secondary button.
The border radius of the secondary button.
The configuration object for disabled buttons
The text color of the disabled button.
The background color of the disabled button.
The border color of the disabled button.
The border radius of the disabled button.
The configuration object for text inputs in the Stytch UI components.
The text color of the text inputs.
The background color of the text inputs.
The color of the placeholder text in the text inputs.
The border color of the text inputs.
The border radius of the text inputs.
The configuration object for your custom logo.
The URL of your custom logo. The image will be resized to fit a max height of 50px, and a max width of 100px.
Optional callbacks that are triggered by various events in the SDK. See more details about the callbacks here.
A callback function that responds to events sent from the SDK.
A callback function that responds to errors in the SDK. It is useful for debugging during development and error handling in production.
Specify custom strings to be used in the prebuilt UI. Consult the message catalog (messages/en.po) for the list of available strings. Each value should be specified using ICU MessageFormat.
Strings that are not defined will use the default English value as a fallback.
See Text Customization for more information.
import React from 'react';
import { StytchLogin } from '@stytch/react';
const Login = () => {
const styles = {
fontFamily: 'Arial',
};
const callbacks = {
onEvent: ({ type, data }) => {
if (type === 'MAGIC_LINK_LOGIN_OR_CREATE') {
console.log('Email magic Link sent', data);
}
},
onError: (data) => {
console.log(data);
},
};
const config = {
products: ['emailMagicLinks', 'oauth'],
emailMagicLinksOptions: {
loginRedirectURL: 'https://example.com/authenticate',
loginExpirationMinutes: 30,
signupRedirectURL: 'https://example.com/authenticate',
signupExpirationMinutes: 30,
createUserAsPending: true,
},
oauthOptions: {
providers: [
{
type: 'google',
one_tap: true,
position: 'floating',
cancel_on_tap_outside: false,
},
{
type: 'microsoft',
provider_params: {
login_hint: 'example_hint@stytch.com',
},
},
],
},
};
// Customize the text in the prebuilt UI via the `strings` parameter
const strings = {
'login.title': 'Welcome back!',
};
return (
<div className="sign-in-container">
<StytchLogin
config={config}
styles={styles}
callbacks={callbacks}
strings={strings}
/>
</div>
);
};
export default Login;