SuperSend TX Provider
Overview
The SuperSend TX provider uses email to send “magic links” that contain URLs with verification tokens that can be used to sign in.
Adding support for signing in via email in addition to one or more OAuth services provides a way for users to sign in if they lose access to their OAuth account (e.g. if it is locked or deleted).
The SuperSend TX provider can be used in conjunction with (or instead of) one or more OAuth providers.
This provider is distributed as the npm package
supersendtx-authjs (peer
dependency: supersendtx). It is
not bundled inside next-auth.
How it works
On initial sign in, a Verification Token is sent to the email address provided. By default this token is valid for 24 hours. If the Verification Token is used within that time (i.e. by clicking on the link in the email) an account is created for the user and they are signed in.
If someone provides the email address of an existing account when signing in, an email is sent and they are signed into the account associated with that email address when they follow the link in the email.
The SuperSend TX provider can be used with both JSON Web Token and database managed sessions, however you must configure a database to use it. It is not possible to enable email sign in without using a database.
Configuration
- Create a SuperSend TX account and verify your sending domain.
- Create an API key (
stx_…) in the dashboard. Save it asAUTH_SUPERSENDTX_KEY(orSUPERSENDTX_API_KEY).
npm install supersendtx-authjs supersendtxAUTH_SUPERSENDTX_KEY=stx_…If you name your environment variable AUTH_SUPERSENDTX_KEY or SUPERSENDTX_API_KEY, the provider will pick it up automatically. You can also pass apiKey explicitly.
import NextAuth from "next-auth"
import SuperSendTX from "supersendtx-authjs"
export const { handlers, auth, signIn, signOut } = NextAuth({
adapter: ...,
providers: [
SuperSendTX({
from: "noreply@yourdomain.com",
}),
],
})-
Do not forget to setup one of the database adapters for storing the Email verification token.
-
You can now start the sign-in process with an email address at
/api/auth/signin.
Customization
Email Body
You can fully customize the sign in email by passing a custom sendVerificationRequest to SuperSendTX():
import NextAuth from "next-auth"
import SuperSendTX from "supersendtx-authjs"
export const { handlers, auth, signIn, signOut } = NextAuth({
adapter: ...,
providers: [
SuperSendTX({
from: "noreply@yourdomain.com",
async sendVerificationRequest({ identifier, url, provider }) {
// custom send logic
},
}),
],
})Full guide: SuperSend TX Auth.js docs.