{"id":18646943,"url":"https://github.com/anfragment/react-email-dynamic","last_synced_at":"2025-10-26T16:34:04.945Z","repository":{"id":231388066,"uuid":"778963223","full_name":"anfragment/react-email-dynamic","owner":"anfragment","description":"Render dynamic React Email templates at runtime.","archived":false,"fork":false,"pushed_at":"2024-09-23T23:51:31.000Z","size":67,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T21:44:08.358Z","etag":null,"topics":["email","react","react-email"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-email-dynamic","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anfragment.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-28T18:56:48.000Z","updated_at":"2025-08-12T09:40:34.000Z","dependencies_parsed_at":"2024-04-03T21:30:50.341Z","dependency_job_id":"fd4328f9-e19b-4459-b00f-3f5fa58c086a","html_url":"https://github.com/anfragment/react-email-dynamic","commit_stats":null,"previous_names":["anfragment/react-email-dynamic"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/anfragment/react-email-dynamic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anfragment%2Freact-email-dynamic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anfragment%2Freact-email-dynamic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anfragment%2Freact-email-dynamic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anfragment%2Freact-email-dynamic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anfragment","download_url":"https://codeload.github.com/anfragment/react-email-dynamic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anfragment%2Freact-email-dynamic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280213279,"owners_count":26291739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","react","react-email"],"created_at":"2024-11-07T06:23:44.803Z","updated_at":"2025-10-26T16:34:04.908Z","avatar_url":"https://github.com/anfragment.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Email Dynamic\n## Introduction\n![GitHub License](https://img.shields.io/github/license/anfragment/react-email-dynamic?color=blue)\n![NPM Downloads](https://img.shields.io/npm/dm/react-email-dynamic)\n\nReact Email Dynamic is a library that allows for **runtime** rendering of templates written with [React Email](https://react.email) components and JSX. This can be useful in scenarios where you want to keep your templates in a database or make them editable by non-developers. It uses [SWC](https://swc.rs) to compile the JSX and [React Email](https://react.email) itself to render the components.\n\n## Installation\n### NPM\n```bash\nnpm install react-email-dynamic\n```\n\n### PNPM\n```bash\npnpm install react-email-dynamic\n```\n\n### Yarn\n```bash\nyarn add react-email-dynamic\n```\n\n## Usage\n```javascript\nimport { render } from 'react-email-dynamic';\n\nconst template = `\n  \u003cHtml lang=\"en\"\u003e\n    \u003cText\u003eHello, World!\u003c/Text\u003e\n    \u003cHr /\u003e\n    \u003cButton href=\"https://example.com\"\u003eClick me\u003c/Button\u003e\n  \u003c/Html\u003e\n`;\n\n(async () =\u003e {\n  const html = await render(template);\n  const plainText = await render(template, {\n    reactEmailRenderOptions: {\n      plainText: true,\n    },\n  });\n})();\n```\n\n## API\n### `render(template: string, options?: RenderOptions): Promise\u003cstring\u003e`\nRenders the given template string into an HTML string asynchronously.\n\n### `renderSync(template: string, options?: RenderOptions): string`\nRenders the given template string into an HTML string synchronously. Use in environments where asynchronous calls are not possible or desired.\n\n### `RenderOptions`\n- `reactEmailRenderOptions?: @react-email/render.Options`: Options passed to the [React Email's render function](https://react.email/docs/utilities/render). Pass `{ plainText: true }` to render plain text instead of HTML.\n- `scope?: Record\u003cstring, any\u003e`: An object serving as the scope for the template. Enables the passing of data and/or custom components. See the [Advanced Usage](#advanced-usage-custom-components-and-data) section for more information.\n- `swcOptions?: swc.Options`: Configuration options for the [SWC compiler](https://swc.rs/docs/usage/core#transform), allowing adjustments to the JSX parser and other compile-time settings.\n\n## Security\nThis library does not perform input validation or sanitization. Passing user input directly to the template string or the scope object can lead to arbitrary code execution and XSS (Cross-Site Scripting) attacks. Only allow a trusted source to modify the template. If you need to pass user input to the template via the `scope` object, ensure each value is sanitized. Possible solutions include using libraries such as [DOMPurify](https://www.npmjs.com/package/dompurify) or [sanitize-html](https://www.npmjs.com/package/sanitize-html).\n\n## Advanced Usage (custom components and data)\nYou can pass custom components and data into the template by using the `scope` option. The values can be any valid React component or data type. **This can lead to vulnerabilities**, so check the [Security](#security) section before using this feature.\n```javascript\nimport { render } from 'react-email-dynamic';\n\nconst template = `\n  \u003cHtml lang=\"en\"\u003e\n    \u003cHeading\u003e{message}\u003c/Heading\u003e\n    \u003cCustomComponent /\u003e\n  \u003c/Html\u003e\n`;\n\nconst scope = {\n  message: 'Hello, World!',\n  CustomComponent: () =\u003e \u003cText\u003eCustom component\u003c/Text\u003e,\n};\n\n(async () =\u003e {\n  const html = await render(template, { scope });\n})();\n```\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanfragment%2Freact-email-dynamic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanfragment%2Freact-email-dynamic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanfragment%2Freact-email-dynamic/lists"}