File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 11import { Resend } from 'resend'
22
3- const resend = new Resend ( process . env . RESEND_API_KEY )
4-
53const FROM_EMAIL = 'Alex Patterson <alex@codingcat.dev>'
64
5+ /** Lazy Resend client — only created when actually needed (avoids build-time crash) */
6+ let _resend : Resend | null = null
7+ function getResendClient ( ) : Resend {
8+ if ( ! _resend ) {
9+ _resend = new Resend ( process . env . RESEND_API_KEY )
10+ }
11+ return _resend
12+ }
13+
714/**
815 * Send a sponsor-related email via Resend.
916 * Falls back to console logging if RESEND_API_KEY is not set.
@@ -20,6 +27,7 @@ export async function sendSponsorEmail(
2027 }
2128
2229 try {
30+ const resend = getResendClient ( )
2331 const { data, error } = await resend . emails . send ( {
2432 from : FROM_EMAIL ,
2533 to : [ to ] ,
You can’t perform that action at this time.
0 commit comments