String customization is not supported for admin portal components
The Stytch B2B SDK allows you to customize the text in the prebuilt UI through the strings parameter. This feature supports both one-off customizations for specific text changes and comprehensive localization efforts for supporting multiple languages.
Text customization requires version 5.25.0, 19.6.0, and/or 21.6.0 or higher of the @stytch/vanilla-js, @stytch/react, and/or @stytch/nextjs packages, respectively.
All customizable strings use ICU MessageFormat.
Available Strings
To see all available strings that can be customized, navigate to the Stytch package in your node_modules and locate the file at:
node_modules/@stytch/vanilla-js/messages/b2b/en.po
node_modules/@stytch/nextjs/messages/b2b/en.po
node_modules/@stytch/react/messages/b2b/en.po
This file contains all the default English strings used throughout the B2B SDK and their corresponding keys.
Basic Usage
Pass your custom strings to the StytchB2B component:
TypeScript
Types for the strings prop is available as the Strings types from version v5.43.0, v19.17.0 and/or v21.17.0 of the @stytch/vanilla-js, @stytch/react, and/or @stytch/nextjs packages, respectively.
The type is a Partial since we recommend only including strings you intend to override, but you use Required<Strings> if you are doing a complete localization and intend to translate every string.
Localization
For complete localization, you can override all strings, then conditionally display the correct string based on the user’s locale:
const spanishStrings = {
"login.title": "Regístrate o inicia sesión",
// ... rest of strings
};
<StytchB2B
config={{
products: [B2BProducts.emailMagicLinks, B2BProducts.oauth, B2BProducts.passwords],
emailMagicLinksOptions: {
loginRedirectURL: "http://localhost:3000/dashboard",
loginExpirationMinutes: 60,
},
}}
// If not provided, the default English strings will be used
strings={locale === "es" ? spanishStrings : {}}
/>
Dynamic Content Handling
Some strings include dynamic content, such as the Organization name or email address. You can use ICU MessageFormat to format these strings dynamically.
/*
Value in the en.po file:
msgid "organizationLogin.title"
msgstr "Continue to {organizationName}"
*/
const strings = {
"organizationLogin.title": "Proceed to {organizationName}",
};
Additionally, some strings include special components as part of the string. You can use these components to customize the text inside the component.
/*
Value in the en.po file:
msgid "password.reset.emailSent.resendText"
msgstr "Didn't get it? <resendButton>Resend email</resendButton>"
*/
const strings = {
"password.reset.emailSent.resendText":
"Didn't receive the email? <resendButton>Retry</resendButton>",
};