02 // Email
Email, in and out
The Resend fragment gives you a complete email runtime: send mail, ingest webhooks, and persist thread history in your own database.
Install
npm install @fragno-dev/resend-fragment @fragno-dev/dbOwn the data
Threads in your DB
Best for
Support + onboarding
Capabilities
Outbound + inbound
Send mail, ingest webhooks, and track status from one fragment.
Reliable threading
Threads read from one canonical local message store for cleaner history.
Typed email APIs
Domains, emails, received mail, threads, and replies all ship with hooks.
Interface
The route surface stays broad enough for real thread workflows while remaining coherent.
Route surface
POST /webhooksGET /domainsGET /domains/:domainIdGET /emailsGET /emails/:emailIdPOST /emailsGET /received-emailsGET /received-emails/:emailIdGET /threadsPOST /threadsGET /threads/:threadIdGET /threads/:threadId/messagesPOST /threads/:threadId/replyWhy it matters
Support, approvals, onboarding, and notifications become more reliable when your app can query them as first-class product data. Resend encapsulates transport concerns and leaves you with typed hooks over durable thread history.
Blueprint
Mount once, then build around owned message history.
Create the server
import { createResendFragment } from "@fragno-dev/resend-fragment";export const resendFragment = createResendFragment( { apiKey: process.env.RESEND_API_KEY!, webhookSecret: process.env.RESEND_WEBHOOK_SECRET!, defaultFrom: "Support <support@example.com>", }, { databaseAdapter, mountRoute: "/api/resend", },);Create a client
import { createResendFragmentClient } from "@fragno-dev/resend-fragment/react";const resend = createResendFragmentClient({ baseUrl: "/api/resend" });const { data: threads } = resend.useThreads();const sendEmail = resend.useSendEmail();const replyToThread = resend.useReplyToThread();Use it
await sendEmail.mutate({ body: { from: "Support <support@example.com>", to: ["customer@example.com"], subject: "Welcome", text: "You're in.", },});await replyToThread.mutate({ path: { threadId }, body: { text: "Thanks — we're on it." },});Outcome
Email becomes queryable application state.
Send from your app
Trigger product mail without hand-rolling provider code.
Keep thread history
See the full conversation in one local timeline.
React to updates
Use inbound events to power automation and human workflows alike.