Getting started

Usage

Render Comark Markdown to email HTML with renderEmail, create a reusable renderer, or render from a pre-parsed document.

Render to email HTML

send-order.ts
import { renderEmail } from 'comark-email'

const { html, text, subject, previewText } = await renderEmail(`
---
email:
  subject: "Your order has shipped!"
  previewText: "Track your package delivery status."
  brandColor: "#0066cc"
---

# Order Shipped

Your order is on its way.

::email-button{href="https://example.com/track" background-color="#0066cc" color="#ffffff"}
Track Package
::
`)

// Pass html directly to your email provider
await sendEmail({ to: user.email, subject, html, text })

Create a reusable renderer

renderer.ts
import { createEmailRenderer } from 'comark-email'

const render = createEmailRenderer({
  email: { brandColor: '#0066cc' },
})

const result = await render(markdownString)

Render from a pre-parsed document

from-document.ts
import { parseMarkdown } from 'comark'
import { renderEmailFromDocument } from 'comark-email'

const doc = await parseMarkdown('---\nemail:\n  subject: Hello\n---\n# Hi')
const { html, subject } = await renderEmailFromDocument(doc)

Try these patterns in the playground.

Copyright © 2026