Skip to content

Resend (Email)

Resend is een developer-vriendelijke email API. We gebruiken het voor alle transactionele emails: bevestigingen, herinneringen, betaallinks en notificaties.

Terminal window
npm install resend
packages/shared/email.ts
import { Resend } from 'resend';
export const resend = new Resend(process.env.RESEND_API_KEY);

Emails worden verstuurd vanuit het domein van het hondenhotel. Het domein moet worden geverifieerd in Resend via DNS records (SPF, DKIM).

From: noreply@[hoteldomain].com
Reply-To: info@[hoteldomain].com

Templates worden gebouwd met React Email voor herbruikbare, gestylde email layouts.

apps/web/emails/booking-confirmed.tsx
import { Html, Body, Heading, Text, Button } from '@react-email/components';
interface BookingConfirmedProps {
clientName: string;
dogName: string;
checkIn: string;
checkOut: string;
paymentUrl?: string;
locale: 'nl' | 'en' | 'es' | 'pap';
}
export function BookingConfirmedEmail({
clientName, dogName, checkIn, checkOut, paymentUrl, locale
}: BookingConfirmedProps) {
const t = getTranslations(locale);
return (
<Html>
<Body>
<Heading>{t('email.booking_confirmed.title')}</Heading>
<Text>{t('email.booking_confirmed.greeting', { name: clientName })}</Text>
<Text>{t('email.booking_confirmed.dog', { dog: dogName })}</Text>
<Text>{t('email.booking_confirmed.dates', { checkIn, checkOut })}</Text>
{paymentUrl && (
<Button href={paymentUrl}>
{t('email.booking_confirmed.pay_now')}
</Button>
)}
</Body>
</Html>
);
}
// Vanuit Supabase Edge Function
import { Resend } from 'npm:resend';
const resend = new Resend(Deno.env.get('RESEND_API_KEY'));
await resend.emails.send({
from: 'noreply@[hoteldomain].com',
to: client.email,
subject: getSubject('booking_confirmed', client.locale),
react: BookingConfirmedEmail({
clientName: client.first_name,
dogName: dog.name,
checkIn: booking.check_in,
checkOut: booking.check_out,
paymentUrl: payment?.sentoo_payment_url,
locale: client.locale,
}),
});

Zie Notificaties voor het volledige overzicht van triggers en inhoud.

RESEND_API_KEY=[api-key]
LimietWaarde
Emails per maand3.000
Emails per dag100
Custom domein

Voor productie is het betaalde plan aanbevolen ($20/maand voor 50.000 emails).