Newsletter
ShipSaaS supports Resend and Beehiiv to manage email subscriptions.
ShipSaaS supports Resend and Beehiiv as built-in providers.
Resend
Section titled “Resend”Create Resend Account
Section titled “Create Resend Account”Create a Resend account at resend.com, and add and verify your website’s domain.
Get API Key
Section titled “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
Section titled “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
Section titled “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
Section titled “Beehiiv”Create Beehiiv Account
Section titled “Create Beehiiv Account”Create a Beehiiv account at beehiiv.com.
Get API Key and Publication ID
Section titled “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
Section titled “Configure Environment Variables”Add the following to your .env file:
.env
BEEHIIV_API_KEY=your-beehiiv-api-keyBEEHIIV_PUBLICATION_ID=your-beehiiv-publication-idUpdate Website Configuration
Section titled “Update 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
Section titled “Customization”Creating a Custom Provider
Section titled “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
Section titled “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