Sign in Form reference API
Here is an example of a fully customized "EmailPassword" configuration for the Sign-in form.
SuperTokens.init({
appInfo: {...},
recipeList: [
EmailPassword.init({
palette: {...},
signInAndUpFeature: {
signInForm: {
style: {
container: {
backgroundColor: "#ffeeff"
},
(...)
},
formFields: [{
id: "email",
label: "Your email",
placeholder: "Enter your email",
validate: async (value) => {
// Custom validation
}
},{
id: "password",
label: "Password",
placeholder: "Enter your password"
}]
}
},
(...)
})
]
});
signInForm
Config values
- style:
- Description: An object to overwrite the Sign up form styles. Please refer to the common customizations guide on how to update the sign in form style.
Example:
style: { container: { marginLeft: "10px", (...) }, link: { color: "orange" } (...) }
- formFields:
- Description: This is an array that lets you overwrite the default email/password fields labels, placeholder and validation methods.
Example:
formFields: [{ id: "email", label: "Your email", placeholder: "Enter your email", validate: async (value) => { // Custom validation } },{ id: "password", label: "Password", placeholder: "Enter your password" }]
- Fields:
- id
- Type:
string
- Description: Id of the form field.
- Example: "email" | "password"
- Required
- Type:
- label
- Type:
string
- Description: Label that will be displayed in the sign up form above the input field.
- Example: "Work Email"
- Required
- Type:
- placeholder
- Type: string
- Description: Placeholder that will be displayed in the sign up inputs before the user types in.
- Example: "Enter your work email",
- Default: Equal to corresponding label.
- Optional
- validate
- Input:
- value: any
- Output:
- Promise:
string
: Return an error string when validation fails.undefined
: Returnundefined
when there are no errors.
- Promise:
- Description: If your field requires a front end validation, you can define a
validate
method that will be called when the user clicks on the Sign up button. - Example: Please refer to the common customizations guide
for an example of how to use
validate
methods. - Optional
- Input:
- optional
- Type: boolean
- Description: Set to
true
if you want to make the field optional. - Example: "Enter your work email"
- Default:
false
- Optional
- id
Note that the email validator that you define for Sign up is also applied automatically to Sign In.
Similarly, the password validator that you define for Sign up is also applied automatically to reset password forms.