UNPKG

1.89 kBTypeScriptView Raw
1// forward declarations
2declare global {
3 namespace NodeJS {
4 // tslint:disable-next-line:no-empty-interface
5 interface ReadableStream {}
6 }
7}
8
9import { ReactElement } from 'react';
10
11/**
12 * Render a React element to its initial HTML. This should only be used on the server.
13 * React will return an HTML string. You can use this method to generate HTML on the server
14 * and send the markup down on the initial request for faster page loads and to allow search
15 * engines to crawl your pages for SEO purposes.
16 *
17 * If you call `ReactDOM.hydrate()` on a node that already has this server-rendered markup,
18 * React will preserve it and only attach event handlers, allowing you
19 * to have a very performant first-load experience.
20 */
21export function renderToString(element: ReactElement): string;
22
23/**
24 * Render a React element to its initial HTML. Returns a Readable stream that outputs
25 * an HTML string. The HTML output by this stream is exactly equal to what
26 * `ReactDOMServer.renderToString()` would return.
27 */
28export function renderToNodeStream(element: ReactElement): NodeJS.ReadableStream;
29
30/**
31 * Similar to `renderToString`, except this doesn't create extra DOM attributes
32 * such as `data-reactid`, that React uses internally. This is useful if you want
33 * to use React as a simple static page generator, as stripping away the extra
34 * attributes can save lots of bytes.
35 */
36export function renderToStaticMarkup(element: ReactElement): string;
37
38/**
39 * Similar to `renderToNodeStream`, except this doesn't create extra DOM attributes
40 * such as `data-reactid`, that React uses internally. The HTML output by this stream
41 * is exactly equal to what `ReactDOMServer.renderToStaticMarkup()` would return.
42 */
43export function renderToStaticNodeStream(element: ReactElement): NodeJS.ReadableStream;
44
45export const version: string;
46
47export as namespace ReactDOMServer;