A powerful, modern email template generator built with Next.js, React Email, and Tailwind CSS. Create beautiful, responsive emails with real-time preview using familiar React JSX syntax.
- π¨ Split-pane Interface: Code editor on the left, live preview on the right
- β‘ Real-time Preview: See your email changes instantly as you type
- π§ React Email Components: Use the powerful React Email component library
- π Tailwind CSS Support: Style emails using Tailwind utility classes with
className - π§ Monaco Editor: Full VS Code-like editing experience with IntelliSense
- π HTML Export: Export your emails as production-ready HTML
- π― JSX Syntax: Write emails in familiar React JSX syntax
- π¨ Modern UI: Built with Tailwind CSS and shadcn/ui components
- π± Responsive Design: Optimized for all screen sizes
- βοΈ Google Drive Integration: Download templates from and upload results to Google Drive
- π₯ Team Collaboration: Share templates through Google Workspace shared drives
- Node.js 18+
- npm or yarn
-
Clone the repository:
git clone https://github.com/yourusername/email-generator.git cd email-generator -
Install dependencies:
npm install
-
Set up Google Drive integration (optional but recommended for team collaboration):
Create a
.env.localfile in the root directory:cp .env.example .env.local
Then follow the Google Cloud Console Setup instructions below.
-
Run the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:3000
Here's a simple email template to get you started:
const WelcomeEmail = ({ name = "User" } = {}) => {
return (
<Html>
<Head />
<Tailwind>
<Body className="font-sans bg-gray-100 m-0 p-0">
<Container className="mx-auto p-5 max-w-2xl">
<Section className="bg-white rounded-lg shadow-md p-6">
<Heading className="text-2xl font-bold text-gray-900 mb-4">
Welcome, {name}! π
</Heading>
<Text className="text-gray-600 mb-6">
Thank you for joining our platform. We're excited to have you!
</Text>
<Button
href="https://example.com/dashboard"
className="bg-blue-600 text-white px-6 py-3 rounded-lg font-semibold"
>
Get Started
</Button>
</Section>
</Container>
</Body>
</Tailwind>
</Html>
);
};All email content must be wrapped in the <Tailwind> component for className support:
<Tailwind>{/* Your email content here */}</Tailwind>Use React Email components for email-compatible HTML:
<Html>- Root HTML wrapper<Head>- Document head<Body>- Document body<Container>- Content container<Section>- Content section<Text>- Text content<Heading>- Headings (h1-h6)<Button>- Buttons with href support<Img>- Images
Use any Tailwind utility classes with className:
<Section className="bg-blue-50 p-6 rounded-lg mb-4">
<Heading className="text-xl font-bold text-blue-900">Your Heading</Heading>
</Section>const NewsletterEmail = ({
name = "Subscriber",
articles = [
{ title: "Getting Started Guide", url: "#" },
{ title: "Best Practices", url: "#" },
{ title: "Tips & Tricks", url: "#" },
],
} = {}) => {
return (
<Html>
<Head />
<Tailwind>
<Body className="font-sans bg-gray-100 m-0 p-0">
<Container className="mx-auto p-5 max-w-2xl">
{/* Header */}
<Section className="bg-white rounded-lg shadow-md mb-6 p-6">
<Heading className="text-3xl font-bold text-center text-gray-900 mb-2">
Weekly Newsletter
</Heading>
<Text className="text-center text-gray-600">
Stay updated with the latest news and updates
</Text>
</Section>
{/* Content */}
<Section className="bg-white rounded-lg shadow-md p-6 mb-6">
<Heading className="text-xl font-semibold text-gray-900 mb-4">
Hello {name}! π
</Heading>
<Text className="text-gray-700 mb-6">
Here are this week's featured articles:
</Text>
{articles.map((article, index) => (
<div key={index} className="mb-4 p-4 bg-gray-50 rounded-lg">
<Heading className="text-lg font-medium text-gray-900 mb-2">
{article.title}
</Heading>
<Button
href={article.url}
className="bg-blue-600 text-white px-4 py-2 rounded text-sm font-medium"
>
Read More
</Button>
</div>
))}
</Section>
{/* Footer */}
<Section className="bg-gray-100 rounded-lg p-6 text-center">
<Text className="text-gray-600 text-sm">
Β© 2024 Your Company. All rights reserved.
</Text>
<Text className="text-gray-500 text-xs mt-2">
<a href="#" className="text-blue-600 underline">
Unsubscribe
</a>{" "}
|
<a href="#" className="text-blue-600 underline">
Update Preferences
</a>
</Text>
</Section>
</Container>
</Body>
</Tailwind>
</Html>
);
};src/
βββ app/
β βββ globals.css # Global styles
β βββ layout.tsx # App layout
β βββ page.tsx # Main application
βββ components/
β βββ CodeEditor.tsx # Monaco editor component
β βββ EmailPreview.tsx # Preview component
β βββ ResizablePanels.tsx # Split-pane layout
β βββ ui/ # shadcn/ui components
β βββ button.tsx
β βββ card.tsx
β βββ separator.tsx
βββ contexts/
β βββ ApiContext.tsx # API configuration context
β βββ GoogleDriveContext.tsx # Google Drive integration context
β βββ ThemeContext.tsx # Theme management context
βββ lib/
βββ apiService.ts # API service utilities
βββ googleDriveService.ts # Google Drive API service
βββ utils.ts # Utility functions
src/app/page.tsx- Main application with email generation logicsrc/components/CodeEditor.tsx- Monaco Editor with React Email IntelliSensesrc/components/EmailPreview.tsx- HTML preview and export functionalitysrc/components/ResizablePanels.tsx- Split-pane layout component
generateHtml()- Transforms JSX code to HTML using Babel and React EmailhandleCodeChange()- Updates editor state when code changes- Monaco
beforeMount- Configures TypeScript definitions for autocompletion
To enable Google Drive integration for team collaboration, follow these steps:
- Go to Google Cloud Console
- Create a new project or select an existing one
- Note your project ID
- In the Google Cloud Console, navigate to APIs & Services > Library
- Search for "Google Drive API"
- Click on it and press Enable
- Go to APIs & Services > OAuth consent screen
- Choose Internal (for Google Workspace organizations) or External
- Fill in the required fields:
- App name: "Email Generator"
- User support email: your email
- Developer contact: your email
- Add scopes:
https://www.googleapis.com/auth/drive.file(Create and manage files)https://www.googleapis.com/auth/drive.readonly(Read files)https://www.googleapis.com/auth/userinfo.email(User email)https://www.googleapis.com/auth/userinfo.profile(User profile)
- Add test users (if using External) or skip (if using Internal)
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth 2.0 Client ID
- Choose Web application
- Add authorized JavaScript origins:
http://localhost:3000(for development)- Your production domain (e.g.,
https://yourdomain.com)
- Copy the Client ID
-
Create a
.env.localfile in your project root:# Google Drive API Configuration NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_client_id_here NEXT_PUBLIC_GOOGLE_API_KEY=your_api_key_here -
Replace the values with your Google Cloud Console credentials:
NEXT_PUBLIC_GOOGLE_CLIENT_ID: Client ID from step 4NEXT_PUBLIC_GOOGLE_API_KEY: API Key from Google Cloud Console (optional, for better performance)
The Google Drive integration supports:
- Download:
.jsx,.tsx,.html,.txtfiles from the "Email Generator Templates" folder - Upload: HTML files (generated emails) and JSX files (source code)
- File Management: All files are stored in a dedicated app folder for easy organization
- File Picker: Simple dropdown interface to select and load files into the editor
- Next.js 15 - React framework with App Router
- TypeScript - Type safety and better DX
- React Email - Email components with Tailwind integration
- Monaco Editor - VS Code-like editor with IntelliSense
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - High-quality component library
- Babel Standalone - JSX transformation in the browser
- Lucide React - Beautiful icon library
-
Import the component in
src/app/page.tsxin thegenerateHtmlfunction:const { Html, Head, Body, Container, Text, Button, Section, Heading, Img, Tailwind, NewComponent, } = await import("@react-email/components");
-
Add it to the execution environment parameters:
const executeTemplate = new Function( "React", "Html", "Head", "Body", "Container", "Text", "Button", "Section", "Heading", "Img", "Tailwind", "NewComponent" // ... rest of function );
-
Add TypeScript definitions in
src/components/CodeEditor.tsx:declare var NewComponent: (props: { className?: string; children?: any; }) => any;
The app uses React Email's <Tailwind> component for className processing. To customize:
-
Pass a
configprop to the<Tailwind>component in your email templates:<Tailwind config={{ presets: [pixelBasedPreset], theme: { extend: { colors: { brand: "#007291", }, }, }, }}>
-
Use React Email's
pixelBasedPresetfor email client compatibility:import { pixelBasedPreset } from "@react-email/components";
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint
This tool is designed for:
- Developers building transactional emails
- Marketing teams creating promotional content
- Product teams designing user onboarding sequences
- Designers prototyping email layouts
- Agencies creating client email templates
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Run tests:
npm test - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- React Email for the amazing email component library
- Monaco Editor for the powerful code editor
- Tailwind CSS for the utility-first CSS framework
- shadcn/ui for the beautiful component library
- π§ Email: support@emailgenerator.com
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
Made with β€οΈ by the Email Generator team