Version 2.0 introduces a prebuild workflow instead of hot reloading. This means email templates are now compiled ahead of time using php artisan react-email:build instead of being rendered on-demand when emails are sent.
Old configuration:
return [
'email_templates_path' => resource_path('views/react-email'),
'blade_output_path' => resource_path('views/vendor/react-email'),
'enable_hot_reload' => env('REACT_EMAIL_HOT_RELOAD', env('APP_DEBUG', false)),
];New configuration:
return [
'path' => resource_path('react-email'),
'build_path' => resource_path('views/react-email'),
];Migration steps:
- Update your
config/react-email.phpfile - Move your React templates from
resources/views/react-emailtoresources/react-email - Update environment variables if used:
REACT_EMAIL_HOT_RELOADis no longer needed (remove it)- Use
REACT_EMAIL_PATHinstead ofLARAVEL_REACT_EMAIL_DIRECTORY - Use
REACT_EMAIL_BUILD_PATHfor output path
Old approach:
public function content(): Content
{
return new Content(
view: 'react-email::welcome-email',
);
}New approach:
public function content(): Content
{
return new Content(
html: 'react-email.welcome-email',
text: 'react-email.welcome-email-text',
);
}In v2.0, you must compile your templates before sending emails:
php artisan react-email:buildThis should be part of your deployment process. Add it to your deployment scripts:
# After composer install and npm install
php artisan react-email:buildThe ReactMailable base class no longer handles hot reloading. It's now a simple abstract class that extends Laravel's Mailable.
No changes required to your existing Mailable classes, but they will no longer compile on-demand.
Preview your emails in the browser:
php artisan react-email:devThis starts the React Email dev server at http://localhost:3000
Generate both Mailable and React template at once:
php artisan make:react-email WelcomeEmailCreates:
app/Mail/WelcomeEmail.phpresources/react-email/welcome-email.tsx
- Update
config/react-email.phpwith new configuration structure - Move React templates from
resources/views/react-emailtoresources/react-email - Update Mailable classes to use
htmlandtextparameters instead ofview - Update view references from
react-email::templatetoreact-email.template - Run
php artisan react-email:buildto compile templates - Add
php artisan react-email:buildto your deployment process - Remove
REACT_EMAIL_HOT_RELOADfrom.envfiles - Test sending emails to ensure they work correctly
- Better Performance: Templates are pre-compiled, no rendering on send
- Faster Email Sending: No Node.js process spawning during email send
- More Reliable: Build-time errors instead of runtime errors
- Better DevX: Live preview server for template development
- Laravel Standard: Uses standard Blade views like other Laravel emails