Skip to content

Commit dddbfa5

Browse files
bidahclaude
andcommitted
🩹 fix(email-preview): show unsubscribe link in email previews
Pass a dummy unsubscribe URL to all email template previews so the unsubscribe link renders in the preview iframe and browser preview. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3321854 commit dddbfa5

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • apps/web/app/(app)/api/email-preview

‎apps/web/app/(app)/api/email-preview/route.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ import { render } from '@react-email/components'
33
import { WelcomeEmail, NewsletterEmail } from '@/lib/email'
44
import { getTemplate, newsletterTemplates } from '@/lib/email/templates/registry'
55

6+
const PREVIEW_UNSUBSCRIBE_URL = '#unsubscribe-preview'
7+
68
const templates: Record<string, (params: URLSearchParams) => React.ReactElement> = {
79
welcome: (params) =>
8-
WelcomeEmail({ name: params.get('name') || 'Jane Doe' }),
9-
newsletter: () => NewsletterEmail({}),
10+
WelcomeEmail({ name: params.get('name') || 'Jane Doe', unsubscribeUrl: PREVIEW_UNSUBSCRIBE_URL }),
11+
newsletter: () => NewsletterEmail({ unsubscribeUrl: PREVIEW_UNSUBSCRIBE_URL }),
1012
}
1113

1214
// Register all newsletter templates from the registry
1315
for (const t of newsletterTemplates) {
14-
templates[t.name] = () => t.component({})
16+
templates[t.name] = () => t.component({ unsubscribeUrl: PREVIEW_UNSUBSCRIBE_URL })
1517
}
1618

1719
export async function GET(request: NextRequest) {

0 commit comments

Comments
 (0)