The preview CLI discovers React email templates, lets you edit their JSON props, and renders the result at desktop and mobile widths. You can inspect or export the generated HTML.
Discover templates
By default, run from your project directory to discover **/*.email.tsx and serve the preview at port 4000:
npx locus-mailEach template needs a default component and named previewData export. For example, create emails/welcome.email.tsx:
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>
);
}If needed, you can customize the root directory, discovery pattern, or port:
npx locus-mail --root . --path 'emails/**/*.email.tsx' --port 4110Use npx locus-mail --help for all options. For a one-off preview without installing the package locally:
npx --package @locus-ui/mail locus-mailPreview a template
Select a discovered template in the preview app. Its previewData supplies the initial props and you can edit the JSON props to see how different data changes the email.
Switch between desktop and mobile widths, inspect the generated HTML, or export it. Changes to the template and its sample props will refresh automatically.
Send a test email
Add locus-mail.config.mjs to your project to enable Send a test email:
import { createResendTransport, defineConfig } from "@locus-ui/mail";
export default defineConfig({
previewSend: {
from: process.env.MAIL_FROM,
transport: createResendTransport({
apiKey: process.env.RESEND_API_KEY,
}),
},
});Set RESEND_API_KEY and MAIL_FROM in the environment before starting the CLI. Use a verified sending domain with Resend. Restart the CLI after changing these values. The CLI does not automatically load .env files.
The button stays disabled without previewSend. When configured, it sends the current editor props to the recipient you enter, independently of production mappers. Credentials remain in the local server configuration.
Preview and production
previewData supplies sample props for local editing. Production email data comes from your mapToSend function. Test sending does not run that mapper, so validate the production path separately using the sending guide.