Auth.js / NextAuth email with Ranla

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

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


Prerequisites

  1. Ranla account + rnl_… 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 @supersend/ranla next-auth
AUTH_SUPERSENDTX_KEY=rnl_your_key_here
# or: RANLA_API_KEY=rnl_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: '[email protected]',
    }),
  ],
})

Users sign in at /api/auth/signin with email. Ranla 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 RANLA_API_KEY API key
baseUrl https://api.ranla.ai 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: '[email protected]',
  async sendVerificationRequest({ identifier, url, provider }) {
    const { SuperSendTX: Client } = await import('@supersend/ranla')
    const tx = new Client(process.env.RANLA_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.