Build emails as React components, preview them locally, and send through a typed API with a swappable transport. Resend is included.
Installation
Requires Node.js 20.19+ on the 20.x line, or 22.12 and later.
npm install @locus-ui/mailCreate a template
Create emails/welcome.email.tsx. Export a default React component and named previewData with sample props:
interface WelcomeProps {
firstName: string;
}
export const previewData = {
firstName: "Wally",
} satisfies WelcomeProps;
export default function WelcomeEmail({ firstName }: WelcomeProps) {
return (
<html lang="en">
<body>
<h1>Welcome, {firstName}!</h1>
</body>
</html>
);
}Templates own their HTML and styling. Preview data is separate from production data loading and sending.
Start the preview
Run from your project directory:
npx locus-mailOpen localhost:4000. The CLI discovers **/*.email.tsx files under the current directory. Choose a template and edit its JSON props to see the result. Template and sample-prop changes refresh automatically.
Next steps
Source and a complete example project are available in the GitHub repository. The published package is @locus-ui/mail on npm.