服务器 React DOM API
react-dom/server API 让你可以在服务器端将 React 组件渲染为 HTML。这些 API 仅在应用的顶层服务器端使用,以生成初始 HTML。框架 可能会为你调用它们。你大多数组件不需要导入或使用它们。
🌐 The react-dom/server APIs let you server-side render React components to HTML. These APIs are only used on the server at the top level of your app to generate the initial HTML. A framework may call them for you. Most of your components don’t need to import or use them.
Web 流的服务器 API
🌐 Server APIs for Web Streams
这些方法仅适用于具有 Web Streams 的环境,包括浏览器、Deno 和一些现代 edge 运行时:
🌐 These methods are only available in the environments with Web Streams, which includes browsers, Deno, and some modern edge runtimes:
renderToReadableStream将 React 树渲染为 可读的 Web 流。resume将prerender恢复为 可读的网络流。
Node.js 流的服务器 API
🌐 Server APIs for Node.js Streams
这些方法仅在具有 Node.js 流: 的环境中可用
🌐 These methods are only available in the environments with Node.js Streams:
renderToPipeableStream将 React 树渲染为可管道的 Node.js 流。resumeToPipeableStream将prerenderToNodeStream恢复为可管道化的 Node.js 流。
非流式环境的旧服务器 API
🌐 Legacy Server APIs for non-streaming environments
这些方法可以在不支持流的环境中使用:
🌐 These methods can be used in the environments that don’t support streams:
renderToString将 React 树渲染为字符串。[renderToStaticMarkup](/reference/react-dom/server/renderToStaticMarkup)将一个非交互式的 React 树渲染为字符串。
与流式 API 相比,它们的功能有限。
🌐 They have limited functionality compared to the streaming APIs.