Newsletter
Learn how to set up and use Resend or Beehiiv for newsletter management
MkSaaS supports multiple newsletter service providers for managing email subscriptions. Currently, it supports Resend and Beehiiv, providing flexible options to manage newsletter subscriptions for your users.
Provider Options
| Provider | Best For | Key Features |
|---|---|---|
| Resend | Developers who need simple email + newsletter | Simple API, Email sending + Contacts management |
| Beehiiv | Content creators and professional newsletters | Rich analytics, Monetization, Growth tools |
Setup with Resend
- Create a Resend account at resend.com
- Click
API Keys>Create API Keyin the dashboard, set the permissions toSend emailsorFull access - Get the
API keyfrom the dashboard, and add it to.envfile:
RESEND_API_KEY=YOUR-RESEND-API-KEY- Update the website config to use Resend for newsletter management:
export const websiteConfig = {
// ...other config
newsletter: {
provider: 'resend', // Newsletter service provider to use
autoSubscribeAfterSignUp: false, // Whether to automatically subscribe users after sign up
},
// ...other config
}Setup with Beehiiv
- Create a Beehiiv account at beehiiv.com
- Go to
Settings>APIto generate an API key - Get your
Publication IDfrom the URL or settings page - Add the credentials to
.envfile:
BEEHIIV_API_KEY=YOUR-BEEHIIV-API-KEY
BEEHIIV_PUBLICATION_ID=YOUR-BEEHIIV-PUBLICATION-ID- Update the website config to use Beehiiv for newsletter management:
export const websiteConfig = {
// ...other config
newsletter: {
provider: 'beehiiv', // Newsletter service provider to use
autoSubscribeAfterSignUp: false, // Whether to automatically subscribe users after sign up
},
// ...other config
}If you are setting up the environment, now you can go back to the Environment Setup guide and continue. The rest of this guide can be read later.
Environment Setup
Set up environment variables
Newsletter System Structure
The newsletter system in MkSaaS is designed with the following components:
This modular structure makes it easy to extend the newsletter system with new providers if needed.
Core Features
- Newsletter subscription and unsubscription management
- Multiple provider support (Resend and Beehiiv)
- User subscription status checking
- Optional automatic subscription for new users
- Modular architecture for easy newsletter service provider switching
- Provider-agnostic interface for consistent API across different services
Usage
Basic Usage
MkSaaS provides simple utility functions for newsletter management.
import { subscribe, unsubscribe, isSubscribed } from '@/newsletter';
// Subscribe a user to the newsletter
const success = await subscribe('user@example.com');
// Unsubscribe a user from the newsletter
const success = await unsubscribe('user@example.com');
// Check if a user is subscribed
const subscribed = await isSubscribed('user@example.com');Using with Email Templates
You can combine the newsletter functionality with the email system to send confirmation emails:
import { subscribe } from '@/newsletter';
import { sendEmail } from '@/mail';
export async function subscribeWithConfirmation(email: string) {
// Subscribe the user to the newsletter
const success = await subscribe(email);
if (success) {
// Send a confirmation email to the user
await sendEmail({
to: email,
template: 'subscribeNewsletter',
context: {
name: email.split('@')[0], // Simple name extraction
unsubscribeUrl: `https://example.com/unsubscribe?email=${encodeURIComponent(email)}`,
},
});
}
return success;
}Customization
Creating a Custom Provider
If you need to use a different newsletter service, you can create a custom provider:
- Create a new file in the
src/newsletter/providerdirectory as a custom newsletter service provider - Implement the
NewsletterProviderinterface
import type {
CheckSubscribeStatusParams,
NewsletterProvider,
SubscribeNewsletterParams,
UnsubscribeNewsletterParams,
} from '@/newsletter/types';
export class CustomNewsletterProvider implements NewsletterProvider {
constructor() {
// Initialize your provider
}
public getProviderName(): string {
return 'CustomProvider';
}
async subscribe({ email }: SubscribeNewsletterParams): Promise<boolean> {
// Implementation for subscribing a user
return true;
}
async unsubscribe({ email }: UnsubscribeNewsletterParams): Promise<boolean> {
// Implementation for unsubscribing a user
return true;
}
async checkSubscribeStatus({ email }: CheckSubscribeStatusParams): Promise<boolean> {
// Implementation for checking subscription status
return true;
}
}- Update the provider selection logic in
index.ts:
import { CustomNewsletterProvider } from './provider/custom-provider';
export const initializeNewsletterProvider = (): NewsletterProvider => {
if (!newsletterProvider) {
switch (websiteConfig.newsletter.provider) {
case 'resend':
newsletterProvider = new ResendNewsletterProvider();
break;
case 'beehiiv':
newsletterProvider = new BeehiivNewsletterProvider();
break;
case 'custom':
newsletterProvider = new CustomNewsletterProvider();
break;
default:
throw new Error(
`Unsupported newsletter provider: ${websiteConfig.newsletter.provider}`
);
}
}
return newsletterProvider;
};FAQ
Which provider should I choose?
- Choose Resend if you already use Resend for transactional emails and want a simple, unified solution for both email sending and newsletter management.
- Choose Beehiiv if you need advanced newsletter features like analytics, monetization, referral programs, and growth tools for professional content creators.
RESEND_AUDIENCE_ID Environment Variable
As of November 15, 2025, the RESEND_AUDIENCE_ID environment variable has been removed from the template, and the newsletter module no longer needs this environment variable.
Please refer to the documentation for more details: Migrating from Audiences to Segments
Best Practices
- Validate Email Addresses: Always validate email addresses before subscribing users
- Confirmation Emails: Send confirmation emails when users subscribe to the newsletter
- Unsubscribe Link: Always include an unsubscribe link in your newsletter emails
- Privacy Policy: Make sure your website has a privacy policy explaining how you use user subscribed data
Video Tutorial
Next Steps
Now that you understand how to work with newsletters in MkSaaS, explore these related integrations:
MkSaaS Docs