Frequently Asked Questions
You know the drill. Questions that get asked oodles
Dark and Light Mode
Email clients handle dark/light mode differently than web browsers. Key considerations:
- Gmail and Outlook Windows have limited color-switching support
- Different handling than web development
Recommended resources:
Preview App Deployment
Yes, you can deploy your own preview app! Use the CLI to build a custom, deployable preview app with your templates.
See CLI Documentation for details.
Gmail and Tailwind
Gmail has strict CSS class restrictions. When using the <Tailwind/>
component:
<Tailwind production={true}> {/* Your email content */}</Tailwind>
Setting production: true
ensures Gmail compatibility by hashing and combining class names.
Monorepo Support
JSX-email works natively with most monorepo setups without additional configuration.
Next.js Build Issues
Error Description
If you encounter this error during Next.js builds:
8058.js from Terser x await isn't allowed in non-async function
This is a known issue with Next.js and Webpack related to server actions in client components.
Solutions
Option 1: Restructure Imports
Pass server actions through props:
import { MyForm } from './MyForm';import { myEmailAction } from './myEmailAction';
export async function Page() { return <MyForm action={myEmailAction} />;}
'use client';export function MyForm({ action }) { // Note the passing of `action` as a prop return <form action={action}>...</form>;}
'use server';import { render } from 'jsx-email';import { MyEmail } from '@/emails/MyEmail';
export async function myEmailAction() { const body = await render(<MyEmail />); // ...}
Option 2: Disable ESM Externals
Modify next.config.js
:
/** @type {import('next').NextConfig} */const nextConfig = { experimental: { esmExternals: false }};
module.exports = nextConfig;
How do I use React context?
Import context helpers from jsx-email instead of from React.
import { createContext, useContext } from 'jsx-email';
Need More Help?
If your question isn’t covered here:
-
Check these resources:
-
For code issues, provide a reproduction:
- Use jsx-email-repro template
- Or create a minimal repository
-
Include reproduction link with your question