We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2411cd3 commit db6721fCopy full SHA for db6721f
1 file changed
lib/sponsor/email-service.ts
@@ -1,9 +1,16 @@
1
import { Resend } from 'resend'
2
3
-const resend = new Resend(process.env.RESEND_API_KEY)
4
-
5
const FROM_EMAIL = 'Alex Patterson <alex@codingcat.dev>'
6
+/** Lazy Resend client — only created when actually needed (avoids build-time crash) */
+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
+
14
/**
15
* Send a sponsor-related email via Resend.
16
* Falls back to console logging if RESEND_API_KEY is not set.
@@ -20,6 +27,7 @@ export async function sendSponsorEmail(
20
27
}
21
28
22
29
try {
30
+ const resend = getResendClient()
23
31
const { data, error } = await resend.emails.send({
24
32
from: FROM_EMAIL,
25
33
to: [to],
0 commit comments