Skip to main content

If you are using our backend SDK that is lesser than the following versions, please visit the older documentation link here.

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