Build Laravel mailables with react.email.
You can install the package via composer:
composer require spectate/laravel-react-emailNext up, install the required NPM packages:
npm i -D typescript react react-email @react-email/components @react-email/render @types/react @types/nodeYou can publish the config file with:
php artisan vendor:publish --tag="react-email-config"If you run composer install during deployments, this way you will automatically regenerate the React Email templates on each deploy.
To enable this, add the following to your composer.json file:
{
"post-install-cmd": [
"@php artisan react-email:build"
]
}Create your first React Email template:
php artisan make:react-email MyFirstEmailYou can run the React Email dev server to preview your templates:
php artisan react-email:devThis will start the dev server and watch for changes in your templates.
Next up, edit the files in resources/views/react-emails and see the changes in your browser.
To support variables in the compiled Blade templates, you can use the following syntax in your React Email templates:
export default function MyEmail() {
return (
<Html>
Hello, $$name$$!
</Html>
);
}This will be compiled to the following Blade template:
Hello, {{ $name }}!By default, on local development environments, the React Email templates are rendered on-the-fly for every send. This can be disabled by setting the REACT_EMAIL_HOT_RELOAD environment variable to false.
You can build the React Email templates to HTML using the react-email:build command:
php artisan react-email:buildThis will build all the templates and output them to resources/views/vendor/react-email.
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.