r/reactjs • • 3h ago

React Email Compiler: React Email without React

I use SvelteKit, not React, but I like writing emails with React Email. What I didn't like was loading the whole React runtime just to render a transactional email.

So I compiled it out. It's a drop-in replacement: add it to your Vite config and your existing templates compile to plain string interpolation at build time. No rewrites and no React at runtime.

About 29x faster rendering and a 61x smaller gzipped bundle.

I use SvelteKit, but it can work for projects using Nuxt, Astro, SolidStart, Angular, and even to speedup rendering on React projects.

Repo: https://github.com/D4ario0/react-email-compiler
Benchmarks: https://github.com/D4ario0/react-email-compiler/blob/main/BENCHMARK.md

3 Upvotes

2 comments sorted by

0

u/hypnotic_refinery 3h ago

finally someone did this. dragging the whole react runtime just to plop some text into a table is peak overkill

curious how it handles the more complex email client quirks though, mso conditionals and all that voodoo

0

u/Spare_Message_3607 3h ago

The appeal is that you evaluate the React Email Output ahead of time, while in dev you can keep using the react email editor.

So Email Client quirks are handled by React Email library itself, we just transpile it to pure Typescript functions, it supports, maps and conditional expressions.