Skip to content

Commit f34a48d

Browse files
committed
renderToMarkup -> renderToHTML
1 parent c0bd72d commit f34a48d

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/content/reference/react-markup/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ It cannot use Client Components and does not hydrate. It is intended to be paire
1313

1414
These APIs can be imported from the React Server environment (e.g. in Server Actions):
1515

16-
* [`renderToMarkup`](/reference/react-markup/renderToMarkup) renders a non-interactive React tree with support for Server Components but not Client Components.
16+
* [`renderToHTML`](/reference/react-markup/renderToHTML) renders a non-interactive React tree with support for Server Components but not Client Components.

src/content/reference/react-markup/renderToMarkup.md renamed to src/content/reference/react-markup/renderToHTML.md

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
---
2-
title: renderToMarkup
2+
title: renderToHTML
3+
canary: true
34
---
45

56

67
<Intro>
78

8-
`renderToMarkup` renders a React tree to non-interactive HTML.
9+
`renderToHTML` renders a React tree to non-interactive HTML.
910

1011
```js
11-
const stream = renderToMarkup(reactNode, options?)
12+
const stream = renderToHTML(reactNode, options?)
1213
```
1314
1415
</Intro>
@@ -19,14 +20,19 @@ const stream = renderToMarkup(reactNode, options?)
1920
2021
## Reference {/*reference*/}
2122
22-
### `renderToMarkup(reactNode, options?)` {/*renderToMarkup*/}
23+
### `renderToHTML(reactNode, options?)` {/*renderToHTML*/}
2324
24-
You can call `renderToMarkup` in a React Server environment (e.g. in a Server Action) to render a non-interactive tree of React components to HTML.
25+
You can call `renderToHTML` to render a non-interactive tree of React components to HTML.
26+
By default, it supports shared components and built-in components.
27+
Server Components are only allowed if used in a React Server environment (e.g. in Server Actions).
28+
You can also use it during Client-Side Rendering but only without Server Components.
29+
30+
When a `<html>` tag is rendered, `renderToHTML` will automatically add `<!DOCTYPE html>` doctype.
2531
2632
```js
27-
import { renderToMarkup } from 'react-dom/server';
33+
import { experimental_renderToHTML as renderToHTML } from 'react-dom/server';
2834

29-
const markup = await renderToMarkup(<App />);
35+
const markup = await renderToHTML(<App />);
3036
```
3137
3238
#### Parameters {/*parameters*/}
@@ -40,28 +46,28 @@ const markup = await renderToMarkup(<App />);
4046
4147
#### Returns {/*returns*/}
4248
43-
`renderToMarkup` returns a Promise that will resolve with the HTML string of the rendered React tree.
49+
`renderToHTML` returns a Promise that will resolve with the HTML string of the rendered React tree.
4450
4551
#### Caveats {/*caveats*/}
4652
47-
* Will throw when Client Components (e.g. `useState` or `useEffect`) are used.
53+
* Will throw when Client APIs (e.g. `useState` or `useEffect`) are used.
4854
4955
---
5056
5157
## Usage {/*usage*/}
5258
5359
### Rendering a React tree as an Email {/*rendering-a-react-tree-as-an-email*/}
5460
55-
Await the call of `renderToMarkup` :
61+
Await the call of `renderToHTML` :
5662
5763
```js {7}
58-
import { renderToMarkup } from 'react-markup';
64+
import { experimental_renderToHTML as renderToHTML } from 'react-markup';
5965
import EmailTemplate from './my-email-template-component.js'
6066

6167
async function action(email, name) {
6268
"use server";
6369
// ... in your server, e.g. a Server Action...
64-
const htmlString = await renderToMarkup(<EmailTemplate name={name} />);
70+
const htmlString = await renderToHTML(<EmailTemplate name={name} />);
6571
// ... send e-mail using some e-mail provider
6672
await sendEmail({ to: email, contentType: 'text/html', body: htmlString });
6773
}

src/sidebarReference.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@
396396
"canary": true,
397397
"routes": [
398398
{
399-
"title": "renderToMarkup",
400-
"path": "/reference/react-markup/renderToMarkup",
399+
"title": "renderToHTML",
400+
"path": "/reference/react-markup/renderToHTML",
401401
"canary": true
402402
}
403403
]

0 commit comments

Comments
 (0)