{"slug": "show-hn-hyper-elements-agents-build-emails-pdfs-images-with-70-less-tokens", "title": "Show HN: Hyper Elements – Agents build emails, PDFs, images with 70% less tokens", "summary": "Hyper Elements released an open-source React library, @hyper-elements/react, that lets developers and AI coding agents generate emails, web pages, PDFs and images from one set of typed elements, with the project claiming agents use 70% fewer tokens. The library renders email HTML and plain text, responsive web HTML, print HTML or PDF, and PNG or SVG images from shared content and a single theme, and runs on a server with no browser, hosted service or API key required. The project also ships a companion JavaScript library and CLI for previewing and testing existing HTML emails locally in Outlook, Gmail and Apple Mail, plus three agent skills installable via `npx skills add hyper-elements/hyper-elements` for Claude Code, Codex and Cursor.", "body_md": "**Build emails, web pages, PDFs, and images with React.**\n\n  One set of elements for developers and AI agents.\n\n[Quick start](#quick-start) ·\n  [AI agents](#build-with-ai-agents) ·\n  [Test in email clients](#preview-and-test-emails-in-outlook-and-gmail-locally) ·\n  [Designs](https://hyperelements.dev/templates) ·\n  [Documentation](https://hyperelements.dev/docs) ·\n  [Website](https://hyperelements.dev)\n\nHyper 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.\n\n- **Reuse your work across formats.** Share content, styles, and components between an email, its web version, and a PDF.\n- **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.\n- **Give agents useful feedback.** Validate designs, inspect layouts as text, and get diagnostics that explain where a problem is and how to fix it.\n- **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.\n- **Render in your own app.** Generate output on your server, with no browser, hosted service, or API key required.\n\nIn a React project (React 18 or later):\n\n```\nnpm install @hyper-elements/react react react-dom\n```\n\nBuild an order update, then render the same content as an email and a web page:\n\n``` js\nimport {\n  Button, Column, Email, Heading, Page, Text, render,\n} from \"@hyper-elements/react\";\n\nfunction OrderUpdate({ name }: { name: string }) {\n  return (\n    <Column style={{ padding: 32, gap: 16 }}>\n      <Heading level={1}>Thanks, {name}.</Heading>\n      <Text>Your order is on its way.</Text>\n      <Button\n        href=\"https://example.com/orders/10482\"\n        style={{ backgroundColor: \"#ef4638\", color: \"#ffffff\" }}\n      >\n        Track your order\n      </Button>\n    </Column>\n  );\n}\n\nconst content = <OrderUpdate name=\"Ada\" />;\nconst { html, text } = await render(<Email width={600}>{content}</Email>);\nconst { html: pageHtml } = await render(<Page width={960}>{content}</Page>);\n```\n\n`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.\n\nUse the same layout and content elements under the root for your destination:\n\n| Build | Root | Render to | \n|---|---|---|\n| Receipts, newsletters, transactional emails | `<Email>` | Email HTML and plain text with `render()` | \n| Landing pages, web versions of emails | `<Page>` | Responsive HTML with `render()` | \n| 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) | \n| 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) | \n\nThe 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.\n\nGive Claude Code, Codex, Cursor, or another coding agent the guide:\n\n```\nnpx skills add hyper-elements/hyper-elements\n```\n\nIt offers three skills: [`hyper-elements`](https://github.com/hyper-elements/hyper-elements/blob/main/skills/hyper-elements/SKILL.md), the guide for writing designs;\n[`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\nanywhere) 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\ndesigns made from your team's templates, within their guardrails, and for writing templates. `--skill email-testing`\ninstalls that one alone.\n\nIn Claude Code they're plugins too: `/plugin marketplace add hyper-elements/hyper-elements`, then\n`/plugin install email-testing@hyper-elements`, `/plugin install brand-templates@hyper-elements` or\n`/plugin install hyper-elements@hyper-elements`.\n\nOr add this to your project's `AGENTS.md` or agent rules:\n\n```\nDesigns use Hyper Elements (@hyper-elements/react). If it isn't installed, install it\nwith react and react-dom. Before writing a design, read\nnode_modules/@hyper-elements/react/GUIDE.md.\nValidate the design, fix errors, review warnings, and inspect outline() before rendering.\n```\n\nThe 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).\n\n`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:\n\n``` js\nimport { outline, validate } from \"@hyper-elements/react\";\n\nconst design = <Email width={600}><OrderUpdate name=\"Ada\" /></Email>;\nconst report = validate(design);\n\nconsole.log(report.diagnostics);\nif (report.valid) console.log(outline(design));\nEmail 600px\n  Column 600px\n    Heading h1 536px \"Thanks, Ada.\"\n    Text 536px \"Your order is on its way.\"\n    Button: background #ef4638 \"Track your order\" → https://example.com/orders/10482\n```\n\nAn agent can spot missing content, incorrect widths, and layout mistakes before rendering, then see the email in each email client with the emulator below.\n\nThe 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](#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.\n\n`@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.\n\nAn 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\nscreenshot, and what it changed.\n\n```\nnpm install @hyper-elements/email-clients\n```\n\nSave this as `preview-email.mjs` beside your `email.html`:\n\n``` js\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { renderInEmailClients } from \"@hyper-elements/email-clients\";\n\nconst html = await readFile(\"email.html\", \"utf8\");\nconst { previews, diagnostics } = await renderInEmailClients(html, {\n  emailClients: [\"outlook\", \"gmail\", \"apple-mail\"],\n});\nawait mkdir(\"out\", { recursive: true });\nfor (const preview of previews) await writeFile(`out/${preview.filename}`, preview.html);\nconsole.log(diagnostics);\n```\n\nRun `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>)`.\n\nYou can also check and preview an HTML email from the shell, with no script or React installation:\n\n```\nnpx @hyper-elements/cli check email.html\nnpx @hyper-elements/cli preview email.html\n```\n\nThe 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:\n\n```\nnpm install -D @hyper-elements/cli playwright-core\nnpx hyper-elements preview email.html --findings\n```\n\nIf you need Chromium, download it once with `npx hyper-elements preview --install-browser`. See [browser setup and findings](https://hyperelements.dev/docs/cli#preview).\n\nTested 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:\n\n[Email client emulator: supported clients, accuracy and options →](https://hyperelements.dev/docs/email-client-emulator)\n\nIn 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.\n\nAll 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/docs/benchmark) · [Reproduce the benchmark](https://github.com/hyper-elements/hyper-elements/blob/main/benchmark)\n\nAcross five image briefs, Hyper Elements reached a passing image **1.65× faster** with **1.8× fewer output tokens** than Canvas 2D (`@napi-rs/canvas`), at the median. **17 of 20** images passed on the first check.\n\nAll 60 isolated runs passed the same text, font, image and layout checks: five briefs, four runs per brief per approach. The speed comparison with Playwright was inconclusive. [Methodology and results](https://hyperelements.dev/docs/benchmark#image-results) · [Reproduce the benchmark](https://github.com/hyper-elements/hyper-elements/blob/main/benchmark)\n\n- **Start from an example:**[Designs](https://hyperelements.dev/templates) ·[Element gallery](https://hyperelements.dev/elements)\n- **Learn the API:**[Writing guide](https://github.com/hyper-elements/hyper-elements/blob/main/packages/react/GUIDE.md) ·[Full reference](https://github.com/hyper-elements/hyper-elements/blob/main/packages/react/REFERENCE.md)\n- **Stay on brand:**[Themes](https://hyperelements.dev/docs/themes)\n- **Test in email clients:**[Email client emulator](https://hyperelements.dev/docs/email-client-emulator) ·[Email client checks](https://hyperelements.dev/docs/diagnostics)\n- **Work from the shell:**[Command line](https://hyperelements.dev/docs/cli) ·[`@hyper-elements/cli`](https://github.com/hyper-elements/hyper-elements/blob/main/packages/cli)\n- **Use it in your app:**[Next.js example](https://github.com/hyper-elements/hyper-elements/blob/main/examples/nextjs-app-router) ·[Email providers](https://github.com/hyper-elements/hyper-elements/blob/main/packages/react/docs/email-providers.md)\n- **Bring existing templates:**[Migrate from React Email](https://github.com/hyper-elements/hyper-elements/blob/main/packages/react/docs/migrate-from-react-email.md) ·[Move from Unlayer Elements](https://github.com/hyper-elements/hyper-elements/blob/main/packages/react/docs/migrating-from-unlayer-elements.md)\n- **Let teammates edit visually:**[Optional Unlayer editor integration](https://github.com/hyper-elements/hyper-elements/blob/main/packages/react/docs/visual-editing.md)\n\nContributions are welcome. Use the Node.js version in [`.nvmrc`](https://github.com/hyper-elements/hyper-elements/blob/main/.nvmrc) and pnpm 9.7 or later, then run `pnpm install`, `pnpm build`, and `pnpm test`. See [CONTRIBUTING.md](https://github.com/hyper-elements/hyper-elements/blob/main/CONTRIBUTING.md) for the development workflow.\n\n[MIT](https://github.com/hyper-elements/hyper-elements/blob/main/LICENSE). Built by the team behind [Unlayer](https://unlayer.com); works independently of the Unlayer platform.", "url": "https://wpnews.pro/news/show-hn-hyper-elements-agents-build-emails-pdfs-images-with-70-less-tokens", "canonical_source": "https://github.com/hyper-elements/hyper-elements", "published_at": "2026-11-24 20:33:37+00:00", "updated_at": "2026-11-24 20:44:50.025555+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "generative-ai"], "entities": ["Hyper Elements", "@hyper-elements/react", "React", "Claude Code", "Codex", "Cursor", "Outlook", "Gmail"], "also_reported_by": [], "takeaway": "Hyper Elements renders one React element tree to email HTML and text, responsive web HTML, print HTML or PDF, and PNG or SVG images, letting agents and developers reuse content and a single theme across formats instead of writing per-output markup.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-hyper-elements-agents-build-emails-pdfs-images-with-70-less-tokens", "markdown": "https://wpnews.pro/news/show-hn-hyper-elements-agents-build-emails-pdfs-images-with-70-less-tokens.md", "text": "https://wpnews.pro/news/show-hn-hyper-elements-agents-build-emails-pdfs-images-with-70-less-tokens.txt", "jsonld": "https://wpnews.pro/news/show-hn-hyper-elements-agents-build-emails-pdfs-images-with-70-less-tokens.jsonld"}}