Skip to content

Site search

Type to search Pages

Docs

Emails

Triggers & sending

View as .md

Send a triggered email by id with sendTransactional(), see the touchpoints that are already wired, and install the system in your own app.

Sending by id

Send a triggered email with sendTransactional(id, { to, data }). It renders the catalog entry against your brand tokens and delivers it through Resend.

Pass only the trigger-specific merge fields in data; the shared brand and footer fields are added for you.

Trigger an email
import { sendTransactional } from '@/lib/email/transactional';

await sendTransactional('password-reset', {
  to: user.email,
  data: {
    user_email: user.email,
    reset_url: `${SITE_URL}/reset-password?token=${token}`,
  },
});

Rendering without sending

renderTransactional(id, { data, theme }) returns the email as an HTML string instead of delivering it — it backs the preview portal and is handy for tests or snapshots.

Both helpers accept an optional theme ('light' or 'dark') and venture; omit them to use the default theme and the active venture.

Wired triggers

The touchpoints are already connected. Signup sends welcome and, when verification is required, verify-email with a tokenised link. The forgot-password flow sends password-reset; completing the reset sends password-changed as a confirmation.

Verification and reset links are backed by short-lived tokens — a PasswordResetToken model and src/lib/auth/tokens.ts. The verify-email page consumes the token and marks the account verified.

Delivery never blocks the flow

Triggered sends are fire-and-forget: a delivery hiccup never fails a signup or a password reset, and without a Resend key sends are logged in development instead.

Install it in your own app

The system is installable like any other kit item. One component renders all 42 emails, so you install the system and send by id rather than copying per-email files — @futurethesislab/emails/<id> pulls in the same system and documents that email's trigger.

Add it, then trigger from your code with sendTransactional().

Terminal
npx @futurethesislab/cli add @futurethesislab/emailsnpx @futurethesislab/cli add @futurethesislab/emails/password-reset