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";
},
})
]
});
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI