File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ This does adjust to your `--dir` option, so if your `emails` directory was insid
2222of ` ./src/emails ` , you would place your static files inside of ` ./src/emails/static ` .
2323
2424These static files are directly served from our preview server by looking into the
25- requests made into that end with ` /static ` and serving the files at that point,
25+ requests made into that end with ` /static ` (i.e. ` http://localhost:3000/static/... ` ) and serving the files at that point,
2626this also allows for you to have images inside of your emails like so:
2727
2828``` jsx
@@ -35,6 +35,31 @@ export default Email(props) {
3535}
3636```
3737
38+ <Info >
39+ This does not mean your images are hosted for you to send the emails,
40+ if you do send your email here and you are using a image or similar inside of ` emails/static `
41+ they will not load properly on the email.
42+ </Info >
43+
44+ Of curse, more often than not you will need to host your images on a CDN, so we recommend
45+ you change the ` src ` to the CDN's base url based on the environment like:
46+
47+ ``` jsx
48+ const baseURL = process .env .NODE_ENV === ' production'
49+ ? ' https://cdn.com'
50+ : ' '
51+
52+ export default Email (props) {
53+ return (
54+ < div>
55+ < img src= {` ${ baseURL} /static/email-logo.png` } / >
56+ < / div>
57+ )
58+ }
59+ ```
60+
61+ You can refer to our [ demo emails source code] ( https://demo.react.email/preview/vercel-invite-user.tsx?view=source ) for an example of how we do this.
62+
3863### How to make the preview server ignore directories
3964
4065Once the preview server has started and is now open on ` localhost ` , the preview server
You can’t perform that action at this time.
0 commit comments