cmjoseph07 / svelty-email

Write and send emails with Svelte ✉️🚀
https://svelte-email.vercel.app
MIT License
35 stars 4 forks source link

Compatibility with Svelte 5 #10

Open dzialdowski opened 3 weeks ago

dzialdowski commented 3 weeks ago

In svelte 5 trying to render email results in the following message:

Error: Component.render(...) is no longer valid in Svelte 5. See https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes for more information

jamesbirtles commented 2 weeks ago

Managed to get around this for now by wrapping the component passed to render with asClassComponent

e.g.

import { render } from 'svelty-email';
import { asClassComponent } from 'svelte/legacy';
import Hello from '$lib/emails/Hello.svelte';

const emailHtml = render({
    template: asClassComponent(Hello),
    props: {
        name: 'Svelte'
    }
});
Rar9 commented 2 weeks ago

is this approach better? https://github.com/carstenlebek/svelte-email/issues/34