Replies: 2 comments
-
Good suggestion @assaf |
Beta Was this translation helpful? Give feedback.
-
The benefits of fixing URLs in the render function:
Manipulating the DOM doesn’t affect URLs in CSS. So I also think it would be helpful to have the base URL accessible as React context. Also it should probably be a transform function, where if you give it a string it creates a transformer function for you. Transformer function could change URLs to go through a tracking endpoint, use CDN for images, skip substitutions (eg %unsubscribe%). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It's too easy to forget that emails need absolute URLs and end up sending emails with broken URLs.
This could be mitigated with something like:
Doing this after rendering to HTML but before
html-to-text
would also apply to plain text emails.Another option is to have a root React component establish a context with the base URL, that Link/Button/Img could access. This would be more efficient — no need to parse/serialize DOM. However, won't cover the case where someone is using their own JSX components instead of React Email components.
PS Fantastic library. Thanks for breathing new life into the email space.
Beta Was this translation helpful? Give feedback.
All reactions