Concepts
renderEmail
Renders a Svelte component to an HTML email string.
Signature
function renderEmail<Comp extends Component<any>, Props extends ComponentProps<Comp>>(
component: Comp,
props: Props,
): stringHow it works
- Renders the Svelte component to an MJML string using
svelte/server - Converts the MJML markup to responsive HTML using
mjml2html - Returns the final HTML string
Usage
import { renderEmail } from '@repo/notifications'
import WelcomeEmail from '$lib/emails/Welcome.svelte'
const html = renderEmail(WelcomeEmail, {
username: 'Jane',
activationUrl: 'https://example.com/activate/abc123',
})The returned html is a complete, self-contained HTML document ready for any email transport.