A modern newsletter management platform built with Next.js and integrated with Resend.com for reliable email delivery.
Integrated editor and app screens:


Clone the repository
bash
git clone <your-repo-url>
cd newsletter-app
Install dependencies
bash
npm install
# or
pnpm install
Set up environment variables
Create a .env.local file in the root directory:
```env
# Resend.com API Configuration
# Get your API key from https://resend.com/api-keys
RESEND_API_KEY=re_123456789...
# Resend.com Audience Configuration # Get your audience ID from https://resend.com/audiences RESEND_AUDIENCE_ID=c304ff13-d608-4ab6-af6d-88ffafbd7370
# Email Configuration FROM_EMAIL=newsletter@yourdomain.com REPLY_TO_EMAIL=support@yourdomain.com
# Application Settings NEXT_PUBLIC_APP_NAME=Newsletter App NEXT_PUBLIC_APP_URL=http://localhost:3000 ```
Get your Resend.com credentials
Sign up at resend.com
Copy the API key and audience ID to your .env.local file
Configure your domain (optional but recommended)
In your Resend.com dashboard, go to Domains
This improves email deliverability
Run the development server
bash
npm run dev
# or
pnpm dev
Open your browser
Navigate to http://localhost:3000
The app includes several API routes for email and subscriber functionality:
POST /api/email/send - Send individual emailsPOST /api/email/test - Send test emailsPOST /api/campaigns/send - Send campaigns to multiple subscribersGET /api/subscribers/contacts - Fetch contacts from Resend.comPOST /api/subscribers/contacts - Add new contact to Resend.comDELETE /api/subscribers/contacts/[id] - Delete contact from Resend.comGET /api/subscribers/audiences - Fetch audiences from Resend.comGET /api/status - Check API connectivity| Variable | Description | Required |
|---|---|---|
RESEND_API_KEY |
Your Resend.com API key | Yes |
RESEND_AUDIENCE_ID |
Your Resend.com audience ID | Yes |
FROM_EMAIL |
Default sender email address | No |
REPLY_TO_EMAIL |
Default reply-to email address | No |
NEXT_PUBLIC_APP_NAME |
Application name | No |
NEXT_PUBLIC_APP_URL |
Application URL | No |
newsletter-app/
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ │ ├── email/ # Email API endpoints
│ │ ├── campaigns/ # Campaign API endpoints
│ │ └── subscribers/ # Subscriber API endpoints
│ ├── campaigns/ # Campaign pages
│ ├── subscribers/ # Subscriber pages
│ ├── settings/ # Settings page
│ └── ...
├── components/ # React components
│ ├── ui/ # shadcn/ui components
│ └── ...
├── hooks/ # Custom React hooks
│ ├── use-email.ts # Email management hook
│ └── use-subscribers.ts # Subscriber management hook
├── lib/ # Utility functions
│ └── resend.ts # Resend.com API client
└── ...
The app uses Tailwind CSS with shadcn/ui components. You can customize the design by:
tailwind.config.ts filecomponents/ui/app/globals.cssTo create custom email templates:
components/email-templates/{{name}} for personalizationThe app is designed to be easily extensible. You can add:
If you're having trouble with the Resend.com API:
This project is licensed under the MIT License.
For support with this application:
Built with ❤️ using Next.js and Resend.com
The email template system provides a comprehensive solution for creating, managing, and using email templates in your newsletter application. It supports both rich text editing and raw HTML editing with real-time preview capabilities.
components/
├── template-editor.tsx # Main template creation/editing component
├── template-card.tsx # Template card for list view
├── template-preview-editor.tsx # Inline editing with preview
└── rich-text-editor.tsx # Rich text editing component
hooks/
└── use-templates.ts # Template management hook
app/
├── templates/
│ ├── page.tsx # Main templates list
│ ├── loading.tsx # Loading skeleton
│ ├── new/
│ │ └── page.tsx # Create new template
│ └── [id]/
│ ├── page.tsx # Template detail view
│ └── edit/
│ └── page.tsx # Edit template page
└── api/
└── templates/
├── route.ts # GET/POST templates
└── [id]/
└── route.ts # GET/PUT/DELETE individual template
Returns all templates
{
"templates": [
{
"id": "string",
"name": "string",
"description": "string",
"category": "string",
"content": "string",
"htmlContent": "string",
"isHtml": "boolean",
"createdAt": "string",
"updatedAt": "string",
"usage": "number"
}
]
}
Creates a new template
{
"name": "string",
"description": "string",
"category": "string",
"content": "string",
"htmlContent": "string",
"isHtml": "boolean"
}
Returns a specific template
Updates a specific template
Deletes a specific template
import { useTemplates } from "@/hooks/use-templates"
const { createTemplate } = useTemplates()
const handleCreate = async () => {
await createTemplate({
name: "Weekly Newsletter",
description: "Standard weekly newsletter template",
category: "Newsletter",
content: "<h1>Hello {{name}}!</h1>",
htmlContent: "<html><body><h1>Hello {{name}}!</h1></body></html>",
isHtml: false
})
}
import { TemplateEditor } from "@/components/template-editor"
<TemplateEditor
template={existingTemplate} // Optional for editing
onSave={handleSave}
onCancel={handleCancel}
loading={loading}
/>
import { TemplatePreviewEditor } from "@/components/template-preview-editor"
<TemplatePreviewEditor
template={template}
onSave={handleSave}
onCancel={handleCancel}
loading={loading}
/>
The system supports template variables that will be replaced when sending emails:
{{name}} - Subscriber's name{{email}} - Subscriber's email{{unsubscribe_url}} - Unsubscribe link{{company_name}} - Your company nameEnable debug mode by adding ?debug=true to any template URL to see additional information.
When contributing to the template system:
$ claude mcp add newsletter-app \
-- python -m otcore.mcp_server <graph>