After installing the React Email package (or cloning a starter), you can start using the command line interface (CLI).
email dev
Where can I place my static files for previewing?
static
directory inside your emails
directory.This does adjust to your --dir
option, so if your emails
directory was inside
./src/emails
, you would place your static files inside ./src/emails/static
.These static files are directly served from our preview server by looking into the
requests made into it that end with /static
(i.e. http://localhost:3000/static/...
) and serving the files at that point,
this also allows for you to have images inside your emails like so:emails/static
, they will not load on the email that was sent.We recommend that you use a different source link to your files depending on whether you’re
running in production or not. Here’s an exampleHow can I define props specific to the email's preview?
PreviewProps
with it as follows:PreviewProps
will be used as props into Email.
So, in a nutshell, it will render the same as if you were to do:How to make the preview server ignore directories?
localhost
, the preview server
reads recursively down into all of your files and directories. This can be disabled
from a directory down by prefixing it with _
, e.g. components -> _components
.So if you wanted to make components for your emails, you could have a file structure as follows:email.tsx
.The heuristics for files to be considered emails
.js, .jsx or .tsx
as their file extensionexport default
expression by matching with the regex/\bexport\s*default\b/gm
email build
.react-email
and builds it.
.react-email
.email start
.react-email
.
email export
out
directory.
email export
is the default or primary way of rendering
email templates.The primary and preferable way is always going to be the render utility,
by passing in the needed data through props, on the exact moment of sending the email.email export
is a secondary way meant for situations where React Email cannot be used optimally.
With this secondary way, comes significant drawbacks, mainly the need for manual templating, which
could be done easily with the render
utility. It being a secondary way, we would strongly recommend
you don’t use it unless you really are forced into it.As an example, two cases where email export
makes itself necessary include:render
’s performance, as typically, the introduced
time in rendering is going to be milliseconds when compared to manual templating.email help <cmd>