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 ThirdPartyPasswordless from "supertokens-node/recipe/thirdpartypasswordless";

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
ThirdPartyPasswordless.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";
},
})
]
});
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI