Better-Notify for Fastify
Add typed notifications to Fastify with zero plugins. Better-Notify runs as a plain import — use it in route handlers, hooks, or background tasks.
Why it fits
- No Fastify plugin needed — just import
- Matches Fastify's schema-first approach
- Works with Fastify's TypeBox/Zod validation
- Use in route handlers or lifecycle hooks
Example
routes/orders.ts
import { mail } from '../lib/notifications';
fastify.post('/orders', async (req, reply) => {
const order = await createOrder(req.body);
await mail.orderConfirmation.send({
to: order.customerEmail,
input: { orderId: order.id, total: order.total },
});
return { orderId: order.id };
});