Overview of Changes
Version 1 includes several breaking changes:- New Renderer class replaces the preprocessor approach
- Tailwind CSS v4 support (with backward compatibility for v3)
- Route-based email preview system
- Enhanced class and style props on components
- Updated plain text rendering API
The
render function from svelte/server is no longer used. You must use the new Renderer class instead.import Renderer from 'better-svelte-email/render';
import tailwindConfig from './tailwind.config.js';
const renderer = new Renderer({ tailwindConfig });
const html = await renderer(EmailTemplate, {
props: { name: 'John' }
});
import Renderer from 'better-svelte-email/render';
import appStyles from 'src/routes/layout.css?raw';
const renderer = new Renderer({ customCSS: appStyles });
const html = await renderer(EmailTemplate, {
props: { name: 'John' }
});
Better Svelte Email will automatically inject the Tailwind config into the email rendering process, allowing you to use the same configuration in both your app and emails.
If you’re upgrading to Tailwind CSS v4, you’ll need to update your class names to match the new syntax. Refer to the Tailwind CSS v4 upgrade guide for detailed migration instructions.
Before (v0.x)
src/routes/email-preview/
├── +page.svelte
└── +page.server.ts
After (v1.x)
src/routes/email-preview/[...email]/
├── +page.svelte
└── +page.server.ts
If you need to use a custom Tailwind configuration with the preview system, pass a
Renderer instance to both createEmail and sendEmail:// src/routes/email-preview/[...email]/+page.server.ts
import { createEmail, sendEmail } from 'better-svelte-email/preview';
import Renderer from 'better-svelte-email/render';
import tailwindConfig from '$lib/tailwind.config.js';
import appStyles from 'src/routes/layout.css?raw';
// For Tailwind v3
const renderer = new Renderer({ tailwindConfig });
// For Tailwind v4
// const renderer = new Renderer({ customCSS: appStyles });
export const actions = {
...createEmail({ renderer }),
...sendEmail({ renderer })
};
Migration Checklist
Use this checklist to ensure you’ve completed all migration steps:- Updated
better-svelte-emailto latest version - Updated
tailwindcssto latest version (if using) - Removed
betterSvelteEmailPreprocessorfromsvelte.config.js - Replaced
renderfromsvelte/serverwithRendererclass - Updated Tailwind configuration (v3 or v4)
- Updated Tailwind class names (if migrating to v4)
- Migrated to
toPlainTextfunction - Moved email preview to
[...email]catch-all route - Updated
createEmailto be called as a function - Updated
pageimport from$app/storesto$app/state - Tested all email templates render correctly
Getting Help
If you encounter issues during migration:- Check the GitHub Issues
- Review the full documentation
- Join the community discussions
What’s New in v1
Beyond the breaking changes, v1 introduces many improvements:- Better performance with the new rendering architecture
- Improved TypeScript support
- Enhanced component APIs with
classandstyleprops - Route-based preview system for better developer experience
- Support for both Tailwind CSS v3 and v4
- More consistent API design across the library