Build

Emails and jobs

Transactional email with Resend and background work with Inngest.

01Emails

Templates in emails/: verification, password reset, change email, magic link, sign-in code, invitation and welcome. Send them with sendEmail() from lib/email/send.ts.

.env.local
RESEND_API_KEY=re_...
EMAIL_FROM=hello@your-domain.com

Without a key, emails go to /dev/mailbox. Preview templates with npm run email:dev.

02Background jobs

Inngest functions live in features/jobs/functions.ts: a welcome email a minute after sign-up and a nightly cleanup of expired records. Queue work with enqueue():

TypeScript
await enqueue("user/created", { userId }, {
  // Runs inline after the response when Inngest isn't configured or running
  fallback: () => sendEmail({ type: "welcome", to: email, name }),
});

Run npx inngest-cli@latest dev locally, and set INNGEST_EVENT_KEY and INNGEST_SIGNING_KEY in production. The nightly cleanup needs Inngest or your own cron.