Skip to main content

Manually generating a link

You can use our backend SDK to generate the reset password link as shown below:

import ThirdPartyEmailPassword from "supertokens-node/recipe/thirdpartyemailpassword";

async function createResetPasswordLink(userId: string, email: string) {
const linkResponse = await ThirdPartyEmailPassword.createResetPasswordLink("public", userId, email);

if (linkResponse.status === "OK") {
console.log(linkResponse.link);
} else {
// user does not exist or is not an email password user
}
}
Multi Tenancy

Notice that the first argument to the function call above is "public". This refers to the default tenant ID that is used in SuperTokens. It means that the generated password reset link can only be consumed by users belonging to the "public" tenant.

If you are using our multi tenancy feature, you can pass in the tenantId that contains this user, which you can fetch by getting the user object for this userId.

Finally, the generated link will use the configured websiteDomain from the appInfo object (in supertokens.init), however, you can change the domain of the generated link to match that of the tenant ID.

Looking for older version of the documentation?
Which UI do you use?
Custom UI
Pre built UI