Email libraries increase bundle size
Adding Nodemailer, React Email or an SDK to your Next.js project increases build size and can cause edge runtime incompatibilities.
Next.js integration
Fire an event from a Server Action or API route. else.events routes it to the right template and delivers through your email provider. No email library in your Next.js bundle.
Adding Nodemailer, React Email or an SDK to your Next.js project increases build size and can cause edge runtime incompatibilities.
React Email components and HTML strings commit to your repository — every copy change means a PR and a deploy.
Calling email libraries inside Server Actions mixes product logic with email delivery in ways that are hard to test and hard to separate.
Email configuration differs between local, preview and production — easy to break, hard to debug.
Call the else.events API from any async Server Action. No client-side exposure of API keys.
Use from route.ts handlers or pages/api endpoints — same fetch pattern, same event schema.
No email SDK import. Just fetch and a JSON payload. Edge-runtime compatible.
Set ELSE_EVENTS_API_KEY per environment. Email behavior is controlled in else.events — not in your Next.js config.
// Next.js App Router — Server Action
// app/actions/billing.ts
'use server';
export async function handleTrialExpiry(userId: string) {
const user = await db.users.findUnique({ where: { id: userId } });
await fetch('https://app.else.events/api/events', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ELSE_EVENTS_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
type: 'trial.expired',
user: { email: user.email, name: user.name },
data: { plan: user.plan, upgrade_url: 'https://app.example.com/pricing' },
}),
});
} Server Actions, route handlers or middleware — the else.events API works from any Next.js server context. No email library in your component tree.
One environment variable. One fetch call. Templates managed outside your repo.