import { getEnvValue } from '@admin/actions/resend/get-env-value' import { Resend } from 'resend' let cachedClient: Resend | null = null let cachedApiKey: string | null = null export function getResendClient(): Resend | null { const apiKey = getEnvValue('BETTERSTART_RESEND_API_KEY') if (!apiKey) { return null } if (!cachedClient || cachedApiKey !== apiKey) { cachedClient = new Resend(apiKey) cachedApiKey = apiKey } return cachedClient }