export command renders your email templates to static HTML or plain text files, ready for use in your application or email service.
Usage
Options
Directory containing your email templates.
Output directory where rendered templates will be saved.
Pretty print the HTML output with proper indentation.
Export templates as plain text (.txt) instead of HTML (.html).
Suppress progress indicators and status messages.
Examples
Basic Export
Export all templates to the defaultout directory:
Pretty Printed HTML
Export with formatted, readable HTML:Plain Text Export
Export templates as plain text files:Custom Output Directory
Export to a specific directory:Silent Mode
Export without progress indicators (useful for CI/CD):Combined Options
Export with multiple options:How It Works
The export command:- Scans the email directory for all template files
- Bundles each template using esbuild with JSX transformation
- Renders templates to HTML using React Email’s render function
- Writes the rendered output to the specified directory
- Copies static assets from
emails/statictoout/static - Cleans up temporary build artifacts
Output Structure
Given this input structure:Using Exported Templates
Node.js
Read and send exported templates:Resend
Sendgrid
Build Process
The export command uses esbuild for fast, efficient bundling:- Bundles all dependencies into single files
- Transforms JSX to JavaScript
- Handles TypeScript automatically
- Resolves imports and path aliases
- Optimizes for production
Pretty vs Minified
Default (Minified)
With —pretty
--pretty during development and debugging. Use minified output in production for smaller file sizes.
CI/CD Integration
Use export in your build pipeline:.github/workflows/build.yml
Troubleshooting
Missing Templates
If templates aren’t being exported:- Ensure they’re in the correct directory (default:
./emails) - Check that files have valid extensions (.tsx, .ts, .jsx, .js)
- Verify templates export a default React component
Build Errors
If you see build errors:- Check for syntax errors in your templates
- Ensure all imports are valid
- Verify that dependencies are installed
Static Files Not Copied
If static assets are missing:- Ensure they’re in
emails/static/directory - Check that the export completed successfully
- Look for the
static/folder in your output directory
Next Steps
Development Server
Preview templates while developing
Build Preview App
Build the preview app for production