Retrieved article excerpt
Open article · Retrieved 2026-11-24T21:22:47.068787+00:00
# Hyper Elements
**Build emails, web pages, PDFs, and images with React.**
One set of elements for developers and AI agents.
[npm version](https://www.npmjs.com/package/@hyper-elements/react)
[Monthly downloads](https://www.npmjs.com/package/@hyper-elements/react)
[Tests](https://github.com/hyper-elements/hyper-elements/actions/workflows/test.yml)
[Code coverage](https://codecov.io/gh/hyper-elements/hyper-elements)
[MIT license](https://github.com/hyper-elements/hyper-elements/blob/main/LICENSE)
[Quick start](https://github.com/hyper-elements/hyper-elements#quick-start) ·
[AI agents](https://github.com/hyper-elements/hyper-elements#build-with-ai-agents) ·
[Test in email clients](https://github.com/hyper-elements/hyper-elements#preview-and-test-emails-in-outlook-and-gmail-locally) ·
[Designs](https://hyperelements.dev/templates) ·
[Documentation](https://hyperelements.dev/docs) ·
[Website](https://hyperelements.dev)
Hyper Elements is an open-source React library for generating content. Write a receipt, invoice, landing page, or social card with typed elements. The engine handles layout and the markup each output needs, including email tables and responsive web HTML.
- **Reuse your work across formats.** Share content, styles, and components between an email, its web version, and a PDF.
- **Keep every output on brand.** Define colors, fonts, sizes, and element styles once in a theme, and every email, page, PDF, and image that uses it follows.
- **Give agents useful feedback.** Validate designs, inspect layouts as text, and get diagnostics that explain where a problem is and how to fix it.
- **Test existing HTML emails locally.** Check and preview Outlook, Gmail and Apple Mail with the companion JavaScript library or CLI. Works with HTML from MJML, React Email or any email builder; no React required, no test sends, no account, nothing uploaded.
- **Render in your own app.** Generate output on your server, with no browser, hosted service, or API key required.
[React components flow through Hyper Elements into email HTML and plain text, responsive web HTML, PDF documents, and PNG or SVG images.](https://github.com/hyper-elements/hyper-elements/blob/main/apps/website/public/img/hyper-elements-overview.png)
## Quick start
In a React project (React 18 or later):
```
npm install @hyper-elements/react react react-dom
```
Build an order update, then render the same content as an email and a web page:
```
import {
Button, Column, Email, Heading, Page, Text, render,
} from "@hyper-elements/react";
function OrderUpdate({ name }: { name: string }) {
return (
<Column style={{ padding: 32, gap: 16 }}>
<Heading level={1}>Thanks, {name}.</Heading>
<Text>Your order is on its way.</Text>
<Button
href="https://example.com/orders/10482"
style={{ backgroundColor: "#ef4638", color: "#ffffff" }}
>
Track your order
</Button>
</Column>
);
}
const content = <OrderUpdate name="Ada" />;
const { html, text } = await render(<Email width={600}>{content}</Email>);
const { html: pageHtml } = await render(<Page width={960}>{content}</Page>);
```
`html` and `text` are the email's HTML and plain text, ready for your [email provider](https://hyperelements.dev/docs/guides/sending). `pageHtml` is a complete responsive web document. No client-side JavaScript is required.
## Choose your output
Use the same layout and content elements under the root for your destination:
| Build | Root | Render to |
| --- | --- | --- |
| Receipts, newsletters, transactional emails | `<Email>` | Email HTML and plain text with `render()` |
| Landing pages, web versions of emails | `<Page>` | Responsive HTML with `render()` |
| Invoices, reports, printable documents | `<Document>` | Print HTML with `render()`, or a PDF with [`renderPdf()`](https://github.com/hyper-elements/hyper-elements/blob/main/packages/react/docs/render-pdf.md) |
| Social cards, Open Graph images, banners | `<Canvas>` | PNG or SVG with [`renderImage()`](https://github.com/hyper-elements/hyper-elements/blob/main/packages/react/docs/render-image.md) |
The PDF and image renderers use separate imports and optional dependencies in Node.js. Diagnostics flag features a destination cannot represent. See [one invoice rendered as email, web, and PDF](https://github.com/hyper-elements/hyper-elements/blob/main/examples/content-workflows) for a complete example.
## Build with AI agents
Give Claude Code, Codex, Cursor, or another coding agent the guide:
```
npx skills add hyper-elements/hyper-elements
```
It offers three skills: [`hyper-elements`](https://github.com/hyper-elements/hyper-elements/blob/main/skills/hyper-elements/SKILL.md), the guide for writing designs;
[`email-testing`](https://github.com/hyper-elements/hyper-elements/blob/main/skills/email-testing/SKILL.md), for previewing and checking any email (a design or HTML from
anywhere) in Outlook, Gmail and the other clients; and [`brand-templates`](https://github.com/hyper-elements/hyper-elements/blob/main/skills/brand-templates/SKILL.md), for
designs made from your team's templates, within their guardrails, and for writing templates. `--skill email-testing`
installs that one alone.
In Claude Code they're plugins too: `/plugin marketplace add hyper-elements/hyper-elements`, then
`/plugin install email-testing@hyper-elements`, `/plugin install brand-templates@hyper-elements` or
`/plugin install hyper-elements@hyper-elements`.
Or add this to your project's `AGENTS.md` or agent rules:
```
Designs use Hyper Elements (@hyper-elements/react). If it isn't installed, install it
with react and react-dom. Before writing a design, read
node_modules/@hyper-elements/react/GUIDE.md.
Validate the design, fix errors, review warnings, and inspect outline() before rendering.
```
The package includes `GUIDE.md` and `REFERENCE.md`, generated from its element definitions so they match the version you installed. Web-based agents can use [llms.txt](https://hyperelements.dev/llms.txt) or [llms-full.txt](https://hyperelements.dev/llms-full.txt).
### A feedback loop the agent can read
`validate()` returns diagnostics with a code, severity, path in the design, and an actionable message. `outline()` shows the layout without making the agent read generated HTML. Try both on the quick-start component:
```
import { outline, validate } from "@hyper-elements/react";
const design = <Email width={600}><OrderUpdate name="Ada" /></Email>;
const report = validate(design);
console.log(report.diagnostics);
if (report.valid) console.log(outline(design));
```
```
Email 600px
Column 600px
Heading h1 536px "Thanks, Ada."
Text 536px "Your order is on its way."
Button: background #ef4638 "Track your order" → https://example.com/orders/10482
```
An agent can spot missing content, incorrect widths, and layout mistakes before rendering, then see the email in each email client with the emulator below.
The same loop runs from the shell, with no script, using [`@hyper-elements/cli`](https://github.com/hyper-elements/hyper-elements/blob/main/packages/cli) (`npm install -D @hyper-elements/cli`): `npx hyper-elements check emails/ --json` validates each design, `outline` prints its layout, `render` writes its HTML and plain text, and `preview` writes each email client's preview. Add `--findings` with the [browser setup below](https://github.com/hyper-elements/hyper-elements#preview-and-test-emails-in-outlook-and-gmail-locally) to draw the previews and collect findings. Exit codes are stable (`1` when a design has errors) for agents and CI.
[Agent setup and examples →](https://hyperelements.dev/docs/guides/ai-agents)
## Preview and test emails in Outlook and Gmail locally
`@hyper-elements/email-clients` is a free JavaScript and TypeScript library for checking existing HTML emails and previewing Outlook, Gmail and Apple Mail locally. Give it the complete HTML from MJML, React Email, an email builder, or a hand-written email. No React is required, and the email is never sent or uploaded.
An agent can do all of this from the [email-testing skill](https://github.com/hyper-elements/hyper-elements/blob/main/skills/email-testing/SKILL.md): the commands, each client's
screenshot, and what it changed.
```
npm install @hyper-elements/email-clients
```
Save this as `preview-email.mjs` beside your `email.html`:
```
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { renderInEmailClients } from "@hyper-elements/email-clients";
const html = await readFile("email.html", "utf8");
const { previews, diagnostics } = await renderInEmailClients(html, {
emailClients: ["outlook", "gmail", "apple-mail"],
});
await mkdir("out", { recursive: true });
for (const preview of previews) await writeFile(`out/${preview.filename}`, preview.html);
console.log(diagnostics);
```
Run `node preview-email.mjs`, then open `out/outlook.html` in Chromium or Chrome. Each preview lists what the client changed. The same API takes a Hyper Elements design: `await renderInEmailClients(<Email><OrderUpdate name="Ada" /></Email>)`.
You can also check and preview an HTML email from the shell, with no script or React installation:
```
npx @hyper-elements/cli check email.html
npx @hyper-elements/cli preview email.html
```
The second command writes `out/clients/email/outlook.html` and the other client previews. To draw them and collect findings automatically, install the CLI and `playwright-core` together, and have Chrome, Edge or Playwright's Chromium installed:
```
npm install -D @hyper-elements/cli playwright-core
npx hyper-elements preview email.html --findings
```
If you need Chromium, download it once with `npx hyper-elements preview --install-browser`. See [browser setup and findings](https://hyperelements.dev/docs/cli#preview).
Tested on Hyper Elements emails and on HTML emails built any other way, the emulator is 98% accurate on average against the real clients. Here's an example email template, a sign-in code, as the emulator draws it in four email clients:
[A sign-in code email in classic Outlook, drawn by the Hyper Elements email client emulator](https://github.com/hyper-elements/hyper-elements/blob/main/apps/website/public/generated/email-clients/keel-sign-in-code-outlook.png)
[The sign-in code email in Gmail on the web, drawn by the emulator](https://github.com/hyper-elements/hyper-elements/blob/main/apps/website/public/generated/email-clients/keel-sign-in-code-gmail.png)
[The sign-in code email in Apple Mail, drawn by the emulator](https://github.com/hyper-elements/hyper-elements/blob/main/apps/website/public/generated/email-clients/keel-sign-in-code-apple-mail.png)
[The sign-in code email in the Gmail app on Android, drawn by the emulator](https://github.com/hyper-elements/hyper-elements/blob/main/apps/website/public/generated/email-clients/keel-sign-in-code-gmail-app.png)
[Email client emulator: supported clients, accuracy and options →](https://hyperelements.dev/docs/email-client-emulator)
## Agent Benchmarks
### Email
In our benchmark of five email briefs, Hyper Elements reached a passing email **2.6× faster** with **3.4× fewer output tokens** than React Email, at the median. It was also **1.3× faster than MJML**. Hyper Elements and MJML both passed **16 of 16** first checks.
[Agent benchmark: Hyper Elements took 33 seconds, used 1,831 output tokens, and passed on the first check in 16 of 16 runs. MJML: 43 seconds, 2,762 output tokens, 16 of 16 first-check passes. Hand-written HTML: 60 seconds, 4,903 output tokens, 6 of 16 first-check passes. React Email: 86 seconds, 6,215 output tokens, 12 of 16 first-check passes. Time and token counts are medians.](https://hyperelements.dev/docs/benchmark)
All four approaches ran in one interleaved batch, with 16 runs each against the same Chromium checks at desktop and mobile widths; all 64 eventually passed. Token counts here measure output tokens, not total usage or cost. [Methodology](https://hyperelements.dev