Auth.js / NextAuth email with SuperSend TX

Auth.js (NextAuth) magic-link sign-in needs an email provider and a database adapter (tokens are stored in the DB).

SuperSend TX ships a drop-in provider: SuperSendTX from supersendtx-authjs (also supersendtx/authjs).


Prerequisites

  1. SuperSend TX account + stx_… API key
  2. Verified sending domain (or Sandbox for self-tests — see Quickstart)
  3. Auth.js app with a database adapter
npm install supersendtx-authjs supersendtx next-auth
AUTH_SUPERSENDTX_KEY=stx_your_key_here
# or: SUPERSENDTX_API_KEY=stx_your_key_here

Setup

// auth.ts
import NextAuth from 'next-auth'
import SuperSendTX from 'supersendtx-authjs'
// import your adapter, e.g. Prisma / Drizzle / …

export const { handlers, auth, signIn, signOut } = NextAuth({
  adapter: /* … */,
  providers: [
    SuperSendTX({
      from: 'noreply@yourdomain.com',
    }),
  ],
})

Users sign in at /api/auth/signin with email. SuperSend TX delivers the magic link (auth=authjs-magic-link tag).


Options

Option Default Purpose
from sandbox-style placeholder Verified sender (set this for production)
apiKey AUTH_SUPERSENDTX_KEY or SUPERSENDTX_API_KEY API key
baseUrl https://api.supersendtx.com API base URL
maxAge 86400 (24h) Token lifetime (seconds)
sendVerificationRequest built-in Custom email body / send logic
client Inject a SuperSendTX instance (tests)

Customize the email

Pass your own sendVerificationRequest (Auth.js pattern):

SuperSendTX({
  from: 'noreply@yourdomain.com',
  async sendVerificationRequest({ identifier, url, provider }) {
    const { SuperSendTX: Client } = await import('supersendtx')
    const tx = new Client(process.env.SUPERSENDTX_API_KEY!)
    await tx.emails.send({
      from: provider.from,
      to: identifier,
      subject: 'Your sign-in link',
      html: `<p><a href="${url}">Sign in</a></p>`,
      text: `Sign in: ${url}`,
    })
  },
})

Or send with React Email from that callback.