Create React App with SSR example
This project show how to implement SSR with a simple React App project.
If you already have a project, I can help you. Just follow the above steps.
Create a file index.ssr.jsx
on src
folder.
This file will contain your StaticRouter.
You can create a express
server and then import your React
string rendered by react-dom/server
.
You will need to eject react-scripts because we will use webpack to generate server rendering build and it's easiest to create jest tests.
yarn eject
First, create a webpack to deal with index.ssr.jsx
as an entry, because you will need basically everything react-scripts
does to render a React App.
You can just copy the ejected config/webpack.config.js
or import into your new webpack file.
Then, change the entry of the webpack to index.ssr.jsx
.
yarn install
yarn start
yarn server
yarn test
👤 Vinicius Tonelli
- Github: @sirshurak
- LinkedIn: @vinicius-tonelli-de-oliveira-845a7a180
Give a ⭐️ if this project helped you!
This project was bootstrapped with Create React App.
This README was generated with ❤️ by readme-md-generator