svelte-email is a library that empowers developers to craft and design email templates using the Svelte framework. It provides a set of Svelte components (such as <Html>, <Button>, <Text>, <Hr>) that abstract away the complex and often archaic requirements of creating table-based, cross-client compatible HTML emails. The library facilitates rendering these Svelte components into static HTML or plain text strings, which can then be dispatched through any preferred email service provider (e.g., Nodemailer, SendGrid, Postmark). Currently at version 0.0.4, the project is in a very early development stage, implying that frequent, potentially breaking changes are highly probable as the library matures. Its key differentiator is bringing the ergonomic and reactive component-driven development paradigm of Svelte to email templating, mirroring the functionality of `react-email` for React, aiming to significantly simplify email design and maintenance workflows.
npm install svelte-emailVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a simple Svelte email component and then use the `render` function to convert it to HTML. It then uses Nodemailer to send the generated HTML email via an SMTP transporter, illustrating the full sending flow.
Refer to the official documentation for the latest API when upgrading. Pin exact `0.0.x` versions to avoid unexpected breaks.
Test emails rigorously across various clients using services like Litmus or Email on Acid. Stick to standard HTML and inline CSS practices where possible.
Ensure your build setup correctly resolves `.svelte` component imports. For non-SvelteKit projects, configure your bundler (Vite, Webpack, Rollup) to handle Svelte component paths appropriately.
Double-check the import path for your Svelte email component (e.g., `import MyEmailComponent from '$lib/emails/MyEmailComponent.svelte';`). Ensure the filename matches the component name if using default exports and that the file exists.
Add `import { render } from 'svelte-email';` at the top of your file where you intend to use the `render` function.Simplify your email's design. Stick to basic HTML tables for layout and inline CSS for styling. Refer to 'email-safe' CSS guides. `svelte-email` components aim to help, but custom styles require careful testing.