Ranla with Next.js
Use Ranla from a server context in Next.js: Route Handlers, Server Actions, background jobs, or any trusted backend code. Do not expose your rnl_… API key in the browser.
1. Install the SDK
npm install @supersend/ranla2. Set your API key
export RANLA_API_KEY=rnl_your_key_hereIn Vercel or Kubernetes, store the same value as an environment variable instead of committing it to the repo.
3. Send from an API route
Create app/api/send-welcome/route.ts:
import { NextResponse } from 'next/server'
import { Ranla } from '@supersend/ranla'
const tx = new Ranla(process.env.RANLA_API_KEY!)
export async function POST() {
const result = await tx.emails.send({
from: '[email protected]',
to: '[email protected]',
subject: 'Welcome to your app',
html: '<p>Your account is ready.</p>',
})
return NextResponse.json(result)
}React Email
Author components with React Email, then pass them to the SDK:
npm install @react-email/render reactawait tx.emails.send({
from: '[email protected]',
to: '[email protected]',
subject: 'Welcome',
react: WelcomeEmail({ name: 'Ada' }),
})Full walkthrough: Send React Email.