renderEmail

renderEmail() converts a Svelte 5 component into email-optimized HTML. It also generates a plain-text version and a metadata object by default.
OptionTypeDefaultDescription
componentSvelte Component-The Svelte component to render.
propsProps-The component’s input properties.
optionsRenderOptions-See Render Options.
Render Options

Configure the rendering process with these options:

OptionTypeDefaultDescription
plainTextbooleantrueWhether to generate a plain-text version of the email.
beautifybooleantrueWhether to beautify the HTML output.
minifybooleantrueWhether to minify the HTML output.

Example

import MyEmail from './MyEmail.svelte';
import { renderEmail } from 'sailkit';

const { html, plainText, metadata } = await renderEmail(
  MyEmail, // Svelte component
  { text: 'Hello World!' }, // Component props
  {
    plainText: true, // Generate a plain-text version of the email.
    beautify: true, // Beautify the HTML output.
    minify: true // Minify the HTML output.
  }
);