The Open Standard for Generative UI
Enhance API reference for React Email package (#387)
subham2c8e91b58f42
diff --git a/docs/content/docs/api-reference/index.mdx b/docs/content/docs/api-reference/index.mdxindex bf9bd8e97..3d1e3f0a9 100644--- a/docs/content/docs/api-reference/index.mdx+++ b/docs/content/docs/api-reference/index.mdx@@ -1,9 +1,9 @@---title: OpenUI SDK-description: API reference for the documented surfaces of @openuidev/react-lang, @openuidev/react-headless, and @openuidev/react-ui.+description: API reference for the documented surfaces of @openuidev/react-lang, @openuidev/react-headless, @openuidev/react-ui, and @openuidev/react-email.----The OpenUI SDK is split into three packages that build on each other:+The OpenUI SDK is split into packages that build on each other:- **`@openuidev/react-lang`** — Core runtime. Define component libraries with Zod schemas, generate system prompts, parse OpenUI Lang, and render streamed output to React. This is the foundation — you need it for any OpenUI integration.@@ -11,6 +11,8 @@ The OpenUI SDK is split into three packages that build on each other:- **`@openuidev/react-ui`** — Prebuilt chat layouts (`Copilot`, `FullScreen`, `BottomTray`) and two ready-to-use component libraries (general-purpose and chat-optimized). Depends on both packages above. Use this for the fastest path to a working chat interface.+- **`@openuidev/react-email`** — API reference for the pre-built email templates library and prompt options.+- **`@openuidev/cli`** — Command-line tool for scaffolding new OpenUI chat apps and generating system prompts or JSON schemas from library definitions.## Packages@@ -28,6 +30,9 @@ The OpenUI SDK is split into three packages that build on each other:Copilot, FullScreen, BottomTray chat layouts, and two built-in component libraries(general-purpose and chat-optimized).</Card>+ <Card title="@openuidev/react-email" href="/docs/api-reference/react-email">+ API reference for the pre-built email templates library and prompt options.+ </Card><Card title="@openuidev/cli" href="/docs/api-reference/cli">openui create (scaffold a Next.js app) and openui generate (system prompt / JSON schema froma library definition).diff --git a/docs/content/docs/api-reference/meta.json b/docs/content/docs/api-reference/meta.jsonindex e88677adc..4f342fafc 100644--- a/docs/content/docs/api-reference/meta.json+++ b/docs/content/docs/api-reference/meta.json@@ -1,5 +1,5 @@{"title": "API Reference","root": true,- "pages": ["index", "react-lang", "react-headless", "react-ui", "cli"]+ "pages": ["index", "react-lang", "react-headless", "react-ui", "react-email", "cli"]}diff --git a/docs/content/docs/api-reference/react-email.mdx b/docs/content/docs/api-reference/react-email.mdxnew file mode 100644index 000000000..9941757c1--- /dev/null+++ b/docs/content/docs/api-reference/react-email.mdx@@ -0,0 +1,58 @@+---+title: "@openuidev/react-email"+description: API reference for the pre-built email templates library and prompt options.+---++Use this package for LLM-driven email template generation with 44 email building blocks.++## Install++```bash tab="npm"+npm install @openuidev/react-email @openuidev/react-lang @react-email/render+```++```bash tab="pnpm"+pnpm add @openuidev/react-email @openuidev/react-lang @react-email/render+```++## `emailLibrary`++Pre-configured `Library` instance with all 44 email components registered. Root component is `EmailTemplate`.++Use `emailLibrary.prompt()` to generate a system prompt for your LLM:++```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();+```++## `emailPromptOptions`++Pre-built `PromptOptions` containing 10 complete email template examples and 30+ rules for high-quality email generation. Passing it to `emailLibrary.prompt()` includes these in the system prompt. Without it, the prompt contains only the component schema.++## Generating HTML++Convert the rendered output to an email-safe HTML string with [`@react-email/render`](https://www.npmjs.com/package/@react-email/render):++```tsx+import { Renderer } from "@openuidev/react-lang";+import { emailLibrary } from "@openuidev/react-email";+import { render } from "@react-email/render";++const html = await render(+ <Renderer response={llmResponse} library={emailLibrary} isStreaming={false} />,+ { pretty: true },+);+```++## Exports++| Export | Type | Description |+| :--- | :--- | :--- |+| `emailLibrary` | `Library` | Ready-to-use library with all 44 email components |+| `emailPromptOptions` | `PromptOptions` | Examples + rules for `emailLibrary.prompt()` |diff --git a/docs/content/docs/openui-lang/meta.json b/docs/content/docs/openui-lang/meta.jsonindex 6f7dd920d..d456c99e4 100644--- a/docs/content/docs/openui-lang/meta.json+++ b/docs/content/docs/openui-lang/meta.json@@ -17,6 +17,7 @@"---Examples---","examples/shadcn-chat","examples/react-native",- "examples/vercel-ai-chat"+ "examples/vercel-ai-chat",+ "examples/react-email"]}diff --git a/packages/react-email/README.md b/packages/react-email/README.mdnew file mode 100644index 000000000..7e24b58a4--- /dev/null+++ b/packages/react-email/README.md@@ -0,0 +1,72 @@+# @openuidev/react-email++React Email components for [OpenUI](https://openui.com) — API reference for the pre-built email templates library and prompt options, ready for LLM-driven email generation.++[](https://www.npmjs.com/package/@openuidev/react-email)+[](https://www.npmjs.com/package/@openuidev/react-email)+[](https://github.com/thesysdev/openui/blob/main/LICENSE)++## Install++```bash+npm install @openuidev/react-email @openuidev/react-lang+# or+pnpm add @openuidev/react-email @openuidev/react-lang+```++**Peer dependencies:** `react >=19.0.0`, `react-dom >=19.0.0`, `@openuidev/react-lang`++## Quick Start++### 1. Generate a system prompt++```ts+import { emailLibrary, emailPromptOptions } from "@openuidev/react-email";++const systemPrompt = emailLibrary.prompt(emailPromptOptions);+```++### 2. Render the email output++```tsx+import { Renderer } from "@openuidev/react-lang";+import { emailLibrary } from "@openuidev/react-email";++function EmailPreview({ response, isStreaming }) {+ return <Renderer response={response} library={emailLibrary} isStreaming={isStreaming} />;+}+```++### 3. Get the HTML++Install [`@react-email/render`](https://www.npmjs.com/package/@react-email/render) to convert the output to an email-safe HTML string:++```bash+npm install @react-email/render+```++```tsx+import { Renderer } from "@openuidev/react-lang";+import { emailLibrary } from "@openuidev/react-email";+import { render } from "@react-email/render";++const html = await render(+ <Renderer response={llmResponse} library={emailLibrary} isStreaming={false} />,+ { pretty: true },+);+```++## Exports++| Export | Description |+| :------------------- | :------------------------------------------------------------- |+| `emailLibrary` | Pre-configured `Library` instance with all 44 email components |+| `emailPromptOptions` | Prompt options with examples and rules for email generation |++## Documentation++Full documentation, guides, and the language specification are available at **[openui.com](https://openui.com)**.++## License++[MIT](https://github.com/thesysdev/openui/blob/main/LICENSE)diff --git a/packages/react-email/package.json b/packages/react-email/package.jsonindex 13d5a8725..1d65e2528 100644--- a/packages/react-email/package.json+++ b/packages/react-email/package.json@@ -1,18 +1,20 @@{"name": "@openuidev/react-email",- "version": "0.1.0",- "description": "React Email components for OpenUI \u2014 44 email building blocks with defineComponent",+ "version": "0.1.3",+ "description": "React Email components for OpenUI — 44 email building blocks with defineComponent","type": "module",- "main": "src/index.ts",- "types": "src/index.ts",+ "main": "dist/index.js",+ "types": "dist/index.d.ts","exports": {".": {- "types": "./src/index.ts",- "default": "./src/index.ts"+ "types": "./dist/index.d.ts",+ "import": "./dist/index.js",+ "default": "./dist/index.js"}},"files": [- "dist"+ "dist",+ "README.md"],"scripts": {"build": "tsc -p tsconfig.build.json",@@ -22,6 +24,7 @@"lint:fix": "eslint ./src --fix","format:fix": "prettier --write ./src","format:check": "prettier --check ./src",+ "prepare": "pnpm run build","ci": "pnpm run lint:check && pnpm run format:check"},"dependencies": {