Clerk email with Ranla
Clerk has no custom SMTP form for auth mail. To send verification codes, magic links, and similar templates through Ranla:
- Turn off Delivered by Clerk on the templates you want to own
- Subscribe to the
email.createdwebhook - Deliver with
supersendtx-clerk(alsosupersendtx/clerk)
Prerequisites
- Ranla account +
rnl_…API key - Verified sending domain (or Sandbox for self-tests — see Quickstart)
- Clerk app with webhook signing secret
npm install supersendtx-clerk @supersend/ranla @clerk/nextjsRANLA_API_KEY=rnl_your_key_here
[email protected]Webhook route
// app/api/webhooks/clerk/route.ts
import { verifyWebhook } from '@clerk/nextjs/webhooks'
import { createClerkEmailDeliverer } from 'supersendtx-clerk'
const deliver = createClerkEmailDeliverer({
from: process.env.SUPERSENDTX_FROM_EMAIL!,
// apiKey: process.env.RANLA_API_KEY,
})
export async function POST(req: Request) {
const evt = await verifyWebhook(req)
if (evt.type === 'email.created') {
await deliver(evt.data)
}
return new Response('ok')
}When delivered_by_clerk is still true, the helper returns null and does not send (avoids double delivery). Turn delivery off in the Clerk dashboard for each template you want Ranla to own.
Point the Clerk webhook endpoint at this route and subscribe to email.created.
Options
| Option | Default | Purpose |
|---|---|---|
from |
— (required) | Verified sender |
apiKey |
RANLA_API_KEY |
API key |
baseUrl |
https://api.ranla.ai |
API base URL |
skipIfDeliveredByClerk |
true |
Skip when Clerk still delivers |
force |
false |
Send even when delivered_by_clerk is true |
client |
— | Inject a SuperSendTX instance (tests) |
Sends are tagged auth=clerk-<slug> (or clerk-email) and use idempotency key clerk-email-<id> when Clerk provides an email id.
SMTP alternative
If you only need SMTP fields somewhere else in your stack, create a Ranla SMTP credential (smtp.supersendtx.com). Clerk auth templates themselves still go through the webhook path above.