# Local preview 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: ```sh npx locus-mail ``` Each template needs a default component and named `previewData` export. For example, create `emails/welcome.email.tsx`: ```tsx interface WelcomeProps { firstName: string; } export const previewData = { firstName: "Wally", } satisfies WelcomeProps; export default function WelcomeEmail({ firstName }: WelcomeProps) { return (

Welcome, {firstName}!

); } ``` If needed, you can customize the root directory, discovery pattern, or port: ```sh npx locus-mail --root . --path 'emails/**/*.email.tsx' --port 4110 ``` Use `npx locus-mail --help` for all options. For a one-off preview without installing the package locally: ```sh npx --package @locus-ui/mail locus-mail ``` ## Preview 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**: ```js 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](/docs/mail/sending).