Better-Notify for tRPC
Better-Notify follows the same philosophy as tRPC — define a typed contract, consume it everywhere. Use the notification client in any tRPC procedure with full end-to-end type safety.
Why it fits
- Same mental model — typed contracts drive the API
- Use in any tRPC procedure or middleware
- Shares Zod schemas between tRPC and Better-Notify
- End-to-end type safety from router to transport
Example
server/routers/auth.ts
import { mail } from '../notifications';
export const authRouter = router({
signup: publicProcedure
.input(z.object({ email: z.string().email(), name: z.string() }))
.mutation(async ({ input }) => {
const user = await createUser(input);
await mail.welcome.send({
to: user.email,
input: { name: user.name },
});
return { userId: user.id };
}),
});