Better-Notify for Next.js
Better-Notify integrates with Next.js API routes, server actions, and middleware. Define your notification catalog once and send from any server-side context — route handlers, server components, or background jobs.
Why it fits
- Works in API routes, server actions, and middleware
- ESM-native — no CJS compatibility issues
- Pairs with React Email for JSX templates
- Deploy to Vercel, Cloudflare, or self-hosted
Example
app/api/invite/route.ts
import { mail } from '@/lib/notifications';
export async function POST(req: Request) {
const { email, teamName } = await req.json();
const result = await mail.teamInvite.send({
to: email,
input: { teamName },
});
return Response.json({ messageId: result.messageId });
}