Skip to content

Latest commit

 

History

History

react-markup

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

react-markup

This package provides the ability to render standalone HTML from Server Components for use in embedded contexts such as e-mails and RSS/Atom feeds. It cannot use Client Components and does not hydrate. It is intended to be paired with the generic React package, which is shipped as react to npm.

Installation

npm install react react-markup

Usage

import{experimental_renderToHTMLasrenderToHTML}from'react-markup';importEmailTemplatefrom'./my-email-template-component.js'asyncfunctionaction(email,name){"use server";// ... in your server, e.g. a Server Action...consthtmlString=awaitrenderToHTML(<EmailTemplatename={name}/>);// ... send e-mail using some e-mail providerawaitsendEmail({to: email,contentType: 'text/html',body: htmlString});}

Note that this is an async function that needs to be awaited - unlike the legacy renderToString in react-dom.

API

react-markup

See https://react.dev/reference/react-markup

Thanks

The React team thanks Nikolai Mavrenkov for donating the react-markup package name.

close