LogoMkSaaS Docs
LogoMkSaaS Docs
HomepageIntroductionCodebaseVideo TutorialsGetting StartedEnvironment Setup
Configuration

Integrations

DatabaseAuthenticationEmailNewsletterStoragePaymentCreditsCron JobsAIAnalyticsNotificationCaptchaChatboxAffiliates

Customization

MetadataFontsThemesImagesi18nBlogDocsComponentsCustom PagesLanding PageUser ManagementAPI Key Management

Codebase

IDE SetupProject StructureFormatting & LintingUpdating the Codebase
X (Twitter)

Newsletter

Learn how to set up and use Resend or Beehiiv for newsletter management

MkSaaS supports Resend and Beehiiv for managing newsletter subscriptions.

Setup

Create Resend Account

Create a Resend account at resend.com.

Get API Key

Click API Keys > Create API Key in the dashboard, set the permissions to Send emails or Full access. Get the API key from the dashboard, and add it to the environment variables file:

.env
RESEND_API_KEY=YOUR-RESEND-API-KEY

Update Website Configuration

src/config/website.tsx
export const websiteConfig = {
  // ...other config
  newsletter: {
    provider: 'resend',
    autoSubscribeAfterSignUp: false,
  },
  // ...other config
}

Create Beehiiv Account

Create a Beehiiv account at beehiiv.com.

Get API Key and Publication ID

Go to Settings > API to generate an API key. Get your Publication ID from the URL or settings page. Add the credentials to the environment variables file:

.env
BEEHIIV_API_KEY=YOUR-BEEHIIV-API-KEY
BEEHIIV_PUBLICATION_ID=YOUR-BEEHIIV-PUBLICATION-ID

Update Website Configuration

src/config/website.tsx
export const websiteConfig = {
  // ...other config
  newsletter: {
    provider: 'beehiiv',
    autoSubscribeAfterSignUp: false,
  },
  // ...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


Usage

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');

Extending New Newsletter Providers

MkSaaS supports extending with new newsletter providers:

  1. Create a new file in the src/newsletter/provider directory (e.g., custom-provider.ts).
  2. Implement the NewsletterProvider interface:
src/newsletter/provider/custom-provider.ts
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;
  }
}
  1. Register the new provider in index.ts:
src/newsletter/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

Video Tutorial

Next Steps

Email

Configure email services

Authentication

Configure user authentication

Analytics

Configure analytics

Storage

Configure storage

Table of Contents

Setup
Create Resend Account
Get API Key
Update Website Configuration
Create Beehiiv Account
Get API Key and Publication ID
Update Website Configuration
Usage
Extending New Newsletter Providers
FAQ
Which provider should I choose?
RESEND_AUDIENCE_ID Environment Variable
Video Tutorial
Next Steps