react/packages/react-markup
Sebastian Markbåge 2cfb221937
[Flight] Allow passing DEV only startTime as an option (#34912)
When you use the `createFromFetch` API we assume that the start time of
the request is the same time as when you call `createFromFetch` but in
principle you could use it with a Promise that starts earlier and just
happens to resolve to a `Response`.

When you use `createFromReadableStream` that is almost definitely the
case. E.g. you might have started it way earlier and you don't call
`createFromReadableStream` until you get the headers back (the fetch
promise resolves).

This adds an option to pass in the start time for debug purposes if you
started the request before starting to parse it.
2025-10-19 16:38:33 -04:00
..
npm Move react-html to react-markup (#30688) 2024-08-14 19:22:44 +02:00
src [Flight] Allow passing DEV only startTime as an option (#34912) 2025-10-19 16:38:33 -04:00
index.js Move react-html to react-markup (#30688) 2024-08-14 19:22:44 +02:00
package.json Bump next prerelease version numbers (#34674) 2025-10-02 00:31:55 +02:00
react-markup.react-server.js Move react-html to react-markup (#30688) 2024-08-14 19:22:44 +02:00
README.md Publish experimental_renderToHTML (#30690) 2024-08-15 08:50:56 +02:00

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_renderToHTML as renderToHTML } from 'react-markup';
import EmailTemplate from './my-email-template-component.js'

async function action(email, name) {
  "use server";
  // ... in your server, e.g. a Server Action...
  const htmlString = await renderToHTML(<EmailTemplate name={name} />);
  // ... send e-mail using some e-mail provider
  await sendEmail({ 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.