Locus Mail

Markdown

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.

Terminal
npm install @locus-ui/mail

Create a template

Create emails/welcome.email.tsx. Export a default React component and named previewData with sample props:

Code
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:

Terminal
npx locus-mail

Open 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

  • Local preview: customize discovery, export HTML, and configure test sending.
  • Sending emails: connect your template to application data and a transport.
  • API reference: inspect the public API and error behavior.

Source and a complete example project are available in the GitHub repository. The published package is @locus-ui/mail on npm.