# Locus Mail
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.
```sh
npm install @locus-ui/mail
```
## Create a template
Create `emails/welcome.email.tsx`. Export a default React component and named `previewData` with sample props:
```tsx
interface WelcomeProps {
firstName: string;
}
export const previewData = {
firstName: "Wally",
} satisfies WelcomeProps;
export default function WelcomeEmail({ firstName }: WelcomeProps) {
return (
Welcome, {firstName}!
);
}
```
Templates own their HTML and styling. Preview data is separate from production data loading and sending.
## Start the preview
Run from your project directory:
```sh
npx locus-mail
```
Open [localhost:4000](http://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](/docs/mail/preview): customize discovery, export HTML, and configure test sending.
- [Sending emails](/docs/mail/sending): connect your template to application data and a transport.
- [API reference](/docs/mail/api): inspect the public API and error behavior.
Source and a complete example project are available in [the GitHub repository](https://github.com/LocusInc/locus-mail). The published package is [@locus-ui/mail on npm](https://www.npmjs.com/package/@locus-ui/mail).