@frontierjs/email-kit
v0.1.9
Published
Mesa email component kit — table-based email components with CSS inlining for transactional email
Maintainers
Readme
@frontierjs/email-kit
Email component kit for Mesa. Table-based, CSS-inlined, Outlook-safe.
Replaces MJML for transactional email built with the Frontier ecosystem.
Install
bun add @frontierjs/email-kit @frontierjs/mesa happy-dom css-treeUsage
In a Mesa template
<script module>
// <script module> runs once, outside any instance — a subject naming the
// recipient is a function of the data, applied by the caller
export const subject = (d) => `Welcome, ${d.firstName}!`
</script>
<script>
import Email from '@frontierjs/email-kit/components/Email.mesa'
import Section from '@frontierjs/email-kit/components/Section.mesa'
import Row from '@frontierjs/email-kit/components/Row.mesa'
import Column from '@frontierjs/email-kit/components/Column.mesa'
import Button from '@frontierjs/email-kit/components/Button.mesa'
import Card from '@frontierjs/email-kit/components/Card.mesa'
import KeyValue from '@frontierjs/email-kit/components/KeyValue.mesa'
import Footer from '@frontierjs/email-kit/components/Footer.mesa'
export let firstName = 'Friend'
export let planName = 'Pro'
export let amount = '$49.00'
</script>
<Email preview="Your account is ready.">
<Section bgcolor="#9fc612">
<Row>
<Column align="center" padding="32px 16px">
<h1 style="color:#fff;font-family:Helvetica,Arial,sans-serif;">
Welcome, {firstName}!
</h1>
</Column>
</Row>
</Section>
<Section>
<Row>
<Column>
<Card heading="Your Plan">
<KeyValue label="Plan" value="{planName}" />
<KeyValue label="Amount" value="{amount}" bold={true} />
</Card>
</Column>
</Row>
<Button href="https://app.example.com" text="Go to Dashboard" />
</Section>
<Section bgcolor="#f4f4f4">
<Footer
company="Example Inc."
unsubscribe="https://example.com/unsubscribe"
/>
</Section>
</Email>Server-side rendering
import { renderEmailFile } from '@frontierjs/email-kit/render'
const data = { firstName: 'Alice', planName: 'Pro', amount: '$49.00' }
const result = await renderEmailFile('./emails/WelcomeEmail.mesa', { data })
// result.html — complete <!DOCTYPE html> with all CSS inlined
// result.text — plain-text fallback
// result.subject — export const subject from <script module>, exactly as exported
// result.css — collected CSS (pre-inlining, for debugging)
// Send via your email provider:
await sendgrid.send({
to: '[email protected]',
from: '[email protected]',
subject: typeof result.subject === 'function' ? result.subject(data) : result.subject,
html: result.html,
text: result.text,
})Components
Layout
| Component | Description |
|-----------|-------------|
| Email | Full email document wrapper with preheader support |
| Section | Full-width table section |
| Row | Single <tr> row |
| TwoCol | Responsive two-column layout (stacks on mobile) |
| Column | <td> cell |
| Spacer | Vertical whitespace row |
Heading, Text, KeyValue, Image and DataTable render a <tr>, so they go
directly in a Section or a Card. Inside a Column (a <td>) the parser moves
the row out of the cell and the layout runs full width; the kit warns once when it
sees that. Wrap them in a Card there, as the example above does.
Content
| Component | Description |
|------------|-------------|
| Heading | Accent heading row |
| Text | Paragraph with email-safe typography |
| Button | CTA with Outlook VML fallback |
| Image | Responsive image with fluid class |
| Link | Inline anchor |
| Divider | Table-cell horizontal rule |
Blocks
| Component | Description |
|-------------|-------------|
| Card | Bordered card with optional heading |
| KeyValue | Label/value pair row — the workhorse for data display |
| DataTable | Structured table with header row |
| Review | Testimonial block with avatar, stars, body |
| Stars | Inline SVG star rating (no external image) |
| Avatar | Inline SVG letter circle |
Structural
| Component | Description |
|-----------|-------------|
| Header | Logo/brand header row |
| Footer | Legal/unsubscribe footer |
| Contact | Name, email, phone, URL block |
| Address | Formatted address with Google Maps link |
Templates
Starter templates live in ./templates/:
WelcomeEmail.mesa— onboarding/welcome email with hero, plan summary, testimonial
How it works
Templates are standard Mesa components. renderEmailFile / renderEmail calls
@frontierjs/mesa's renderComponent pipeline with target: 'email':
- Recursively compiles all
.mesaimports - Executes components in a happy-dom virtual DOM
- Collects all
<style>block CSS across the tree - Inlines CSS into
style=""attributes (CSS variables resolved,@mediapreserved in<head>) - Wraps in a complete
<!DOCTYPE html>document with MSO/VML namespaces
Email client compatibility
Nothing here has been opened in a real mail client. Every claim below is a claim about the HTML this package emits, verified by reading the output — not a claim about what Outlook or Gmail does with it. The techniques are the standard ones and the markup is shaped for them; whether they land is untested, and saying otherwise would be the one thing an email kit must not get wrong.
What the output actually carries:
- Outlook — VML bulletproof buttons, MSO conditional comments, table layout.
The conditional-comment handling is fragile and
docs/is the only record of why the markup is shaped the way it is — read it before touching it - Gmail — styles inlined onto
style="", no<style>block in the body - Apple Mail —
@mediablocks preserved in<head>for responsive rules - Mobile — two-column layouts declare
@media (max-width: 600px)to stack
Proving it needs a real send to a matrix of clients, which this package has no harness for. Until it does, treat the list as intent.
