The Open Standard for Generative UI
---
title: "React Email"
---
<Steps>
<Step title="Import the email library">
Use emailLibrary from @openuidev/react-email. It covers 44 email-safe components, including headers, feature grids, pricing cards, and checkout tables.
</Step>
<Step title="Generate the email prompt" source="https://www.openui.com/docs/api-reference/react-email">
Build the system prompt from emailLibrary and emailPromptOptions, so the model composes emails only from those components.
```ts title="system-prompt.ts"
import { emailLibrary, emailPromptOptions } from "@openuidev/react-email";
// With examples and rules (recommended)
const systemPrompt = emailLibrary.prompt(emailPromptOptions);
// Without — schema only, no examples or rules
const minimalPrompt = emailLibrary.prompt();
```
</Step>
<Step title="Preview and export HTML" source="https://github.com/thesysdev/openui/blob/main/examples/miscellaneous/react-email/src/hooks/useEmailRendering.tsx">
Stream the response into Renderer from @openuidev/react-lang for a live preview, then convert the email to client-compatible HTML with @react-email/render.
```tsx title="EmailPreview.tsx"
"use client";
import { emailLibrary } from "@openuidev/react-email";
import { Renderer } from "@openuidev/react-lang";
import { render } from "@react-email/render";
interface EmailPreviewProps {
openuiCode: string;
isStreaming: boolean;
}
// Live preview: re-renders as the OpenUI Lang response streams in.
export function EmailPreview({ openuiCode, isStreaming }: EmailPreviewProps) {
return <Renderer response={openuiCode} library={emailLibrary} isStreaming={isStreaming} />;
}
// After streaming ends, turn the same response into email-client HTML.
export function renderToHtml(openuiCode: string) {
return render(<Renderer response={openuiCode} library={emailLibrary} isStreaming={false} />, {
pretty: true,
});
}
```
</Step>
</Steps>