@i18n-email/resend
v0.2.0
Published
Resend integration for i18n-email - adds locale to emails.send()
Downloads
58
Maintainers
Readme
@i18n-email/resend
Resend integration for i18n-email. Wraps a Resend instance so emails.send() accepts an optional locale field — when set, the email is translated before sending.
Install
bun add @i18n-email/resend
# or
npm install @i18n-email/resendRequires i18n-email, resend, and react as peer dependencies.
Usage
import { Resend } from "resend";
import { withResend } from "@i18n-email/resend";
import { WelcomeEmail } from "./emails/welcome";
const resend = withResend(new Resend("re_..."), {
openaiApiKey: "sk-...",
});
// Translated — locale is set
await resend.emails.send({
from: "[email protected]",
to: "[email protected]",
locale: "fr",
subject: "Welcome!",
react: <WelcomeEmail name="Dan" />,
});
// Not translated — no locale, works like normal Resend
await resend.emails.send({
from: "[email protected]",
to: "[email protected]",
subject: "Welcome!",
react: <WelcomeEmail name="Dan" />,
});All other Resend methods (emails.get, contacts, domains, etc.) are untouched.
API
withResend(resend, i18nOptions)
| Parameter | Type | Description |
| ------------- | ----------------- | ----------------------------------------------- |
| resend | Resend | A Resend instance |
| i18nOptions | I18nEmailConfig | Same config object as createI18nEmail accepts |
Returns an I18nResend — a proxied Resend instance where emails.send() accepts an optional locale field.
When locale is set:
- The
subjectandreact/htmlare translated viai18n-email - The
localefield is stripped before calling Resend - Resend receives the translated
subjectandhtml
When locale is omitted, the call passes through to Resend unchanged.
