Newsletter
Learn how to configure and use Resend or Beehiiv for email subscription management
ShipSaaS supports Resend and Beehiiv to manage email subscriptions.
Setup
ShipSaaS supports Resend and Beehiiv as built-in providers.
Resend
Create Resend Account
Create a Resend account at resend.com, and add and verify your website's domain.
Get API Key
Navigate to Resend Dashboard > API Keys, create a new API key, and ensure that it has permission to send emails.
Configure Environment Variables
Add the following to your .env file:
.env
RESEND_API_KEY=re_xxxxxxxxxxxxNote: When using Resend, the RESEND_API_KEY is shared between the email module and the email subscription module.
Update Website Configuration
Update your website configuration to use Resend for email subscription management:
src/config/website.ts
export const websiteConfig = {
// ...other configurations
newsletter: {
enable: true,
provider: 'resend',
autoSubscribeAfterSignUp: true, // Whether to automatically subscribe users after registration
},
// ...other configurations
}Beehiiv
Create Beehiiv Account
Create a Beehiiv account at beehiiv.com.
Get API Key and Publication ID
- Navigate to
Settings>APIto generate an API key. - Obtain your
Publication IDfrom the URL or the settings page.
Configure Environment Variables
Add the following to your .env file:
.env
BEEHIIV_API_KEY=your-beehiiv-api-key
BEEHIIV_PUBLICATION_ID=your-beehiiv-publication-idUpdate Website Configuration
Update your website configuration to use Beehiiv for email subscription management:
src/config/website.ts
export const websiteConfig = {
// ...other configurations
newsletter: {
enable: true,
provider: 'beehiiv',
autoSubscribeAfterSignUp: true, // Whether to automatically subscribe users after registration
},
// ...other configurations
}If you are setting up your environment, you can now return to the Environment Configuration document and continue. The remainder of this document can be read later.
Environment configuration set environment variables
Customization
Creating a Custom Provider
If you need to use a different email subscription service, you can create a custom email subscription provider:
- Create a new file in the
src/newsletter/providerdirectory. - Implement the
NewsletterProviderinterface.
src/newsletter/provider/custom-provider.ts
import type {
CheckSubscribeStatusParams,
NewsletterProvider,
SubscribeNewsletterParams,
UnsubscribeNewsletterParams,
} from '@/newsletter/types';
export class CustomNewsletterProvider implements NewsletterProvider {
constructor() {
// Initialize your email subscription provider
}
public getProviderName(): string {
return 'custom';
}
async subscribe({ email }: SubscribeNewsletterParams): Promise<boolean> {
// Implementation to subscribe a user
return true;
}
async unsubscribe({ email }: UnsubscribeNewsletterParams): Promise<boolean> {
// Implementation to unsubscribe a user
return true;
}
async checkSubscribeStatus({ email }: CheckSubscribeStatusParams): Promise<boolean> {
// Implementation to check subscription status
return true;
}
}- Register the new email subscription provider in the
providerRegistryinsrc/newsletter/index.ts:
src/newsletter/index.ts
import { CustomNewsletterProvider } from './provider/custom-provider';
const providerRegistry: Record<NewsletterProviderName, ProviderFactory> = {
resend: () => new ResendNewsletterProvider(),
beehiiv: () => new BeehiivNewsletterProvider(),
custom: () => new CustomNewsletterProvider(),
};Next Steps
Now that you know how to use email subscriptions in ShipSaaS, explore these related topics:
-
Email - Configure email service
-
Authentication - Configure user authentication
-
Analytics - Configure analytics services
-
Storage - Configure storage services