You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[react-stdio](https://github.com/mjackson/react-stdio) lets you render [React](https://facebook.github.io/react/) components on the server, regardless of the backend technology you're using.
6
+
[react-stdio](https://github.com/ReactTraining/react-stdio) lets you render [React](https://reactjs.org/) components on the server, regardless of the backend technology you're using.
7
7
8
8
As its name suggests, other processes communicate with react-stdio using standard streams. The protocol is JSON, so any environment that can spawn a child process and write JSON to its stdin can use the server. Requests are handled serially, so responses are issued in the same order requests are received.
9
9
10
10
## Installation
11
11
12
-
Using [npm](https://npmjs.com):
12
+
If you have node installed, you can install using npm:
13
13
14
14
$ npm install -g react-stdio
15
15
16
+
This will put the `react-stdio` executable in your [`npm bin`](https://docs.npmjs.com/cli/bin).
17
+
18
+
If you don't have node installed, you can download the executable for your architecture from [the releases page](https://github.com/ReactTraining/react-stdio/releases).
19
+
16
20
## Usage
17
21
18
-
Once you've installed the server, you will have a `react-stdio` binary available (assuming `node_modules/.bin` is in your `$PATH`). Execute it to start the server.
22
+
After installation, execute `react-stdio` to start the server.
19
23
20
24
To render a React component, write a JSON blob to stdin with any of the following properties:
21
25
22
26
component The path to a file that exports a React component (required)
23
27
props Any props you want to pass to the component (optional, default is {})
24
28
render The type of rendering (optional, default is renderToString)
25
29
26
-
If the request is successful, the server will put a JSON blob with `{"html":"..."}` on stdout. If the request fails for some reason, the JSON will have an `error` property instead of `html`.
30
+
If the request is successful, the server will put a JSON blob with `{"html":"...","context":...}` on stdout. If the request fails for some reason, the JSON will have an `error` property instead of `html`.
27
31
28
32
Example:
29
33
@@ -47,7 +51,7 @@ Also, since react-stdio uses the `stdout` stream for all program output, all wri
0 commit comments