Skip to content

Commit 7732a2a

Browse files
committed
updates README
1 parent f33676a commit 7732a2a

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015-present LeanJS
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+50-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,50 @@
1-
# react-scripts-ssr
1+
# react-scripts-ssr
2+
3+
Create React apps with server-side rendering (SSR) with no configuration
4+
5+
# Installation
6+
7+
`npm install react-scripts-ssr --save-dev`
8+
9+
# Getting started
10+
11+
## Steps
12+
13+
### Step 1
14+
15+
In the scripts section of your package.json:
16+
17+
- Replace `"start": "react-scripts start"` with `"start": "react-scripts-ssr start",`
18+
- Add `"build-server": "react-scripts-ssr build-server",`
19+
20+
### Step 2
21+
22+
Create the following file in src/server.js
23+
24+
```javascript
25+
const React = require("react");
26+
const express = require("express");
27+
const { createSSRMiddleware } = require("react-scripts-ssr");
28+
const { renderToString } = require("react-dom/server");
29+
import App from "./App";
30+
31+
const server = express();
32+
33+
server.use(
34+
createSSRMiddleware((req, res, next) => {
35+
const body = renderToString(<App />);
36+
next({ body }, req, res);
37+
})
38+
);
39+
40+
const PORT = process.env.REACT_APP_SERVER_SIDE_RENDERING_PORT || 8888;
41+
server.listen(PORT, () => {
42+
console.log(`server running on port ${PORT}`);
43+
});
44+
```
45+
46+
You can edit the server.js file with your custom code and other middlewares.
47+
48+
### Step 3
49+
50+
`npm start`

0 commit comments

Comments
 (0)