Skip to main content

Changing OTP format

By default, the generated OTP is 6 digits long and is numbers only. You can change this to be any length you like and have any charset by providing the getCustomUserInputCode function.

import SuperTokens from "supertokens-node";
import Passwordless from "supertokens-node/recipe/passwordless";

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
Passwordless.init({
contactMethod: "EMAIL", // This example will work with any contactMethod
// This example works with the "USER_INPUT_CODE_AND_MAGIC_LINK" and "USER_INPUT_CODE" flows.
flowType: "USER_INPUT_CODE_AND_MAGIC_LINK",

getCustomUserInputCode: async (userCtx) => {
// TODO:
return "123abcd";
},
})
]
});
Which frontend SDK do you use?
supertokens-web-js / mobile
supertokens-auth-react