React Server Side Rendering
React Server Side Rendering
Jeremy Zerr
Site: https://www.zerrtech.com
https://www.linkedin.com/in/jrzerr
https://twitter.com/jrzerr
The Plan
/heroes
/heroes/0
The App - Code
Zerrtech/zerrtech-react-ssr-demo
step-1-normal-app
step-2-ssr-initial
step-3-ssr-server-seed
step-4-ssr-api
1
Initial App Demo
Branch: step-1-normal-app
Initial page load has nothing!
Combined with SSR caching, this can mean that each page is
only rendered once and used by many users. Loading indicators
added while waiting for API calls wouldn’t really show up, better
user experience.
1
Rendering HTML
only page
I have version 71
Server fetches data needed for the home page, seeds your component
state, renders your React components, gets the HTML created by them,
stuffs it into your React root in index.html and returns it to the browser
Browser React component does not need to fire off API calls because
they were already done on the server
2
Initial SSR
Branch: step-2-ssr-initial
Initial page load has
our loading indicator
Babel compiled
Express
Build prod with yarn build, then start SSR with yarn start:ssr
Step 2 - server.js
2
Initial SSR
Review
staticContext is provided
by React router
withRouter()
3
SSR Server Seed
Review
HeroList
getInitialState
checks for existing
data
React SSR Summary
Jeremy Zerr
Site: https://www.zerrtech.com
https://www.linkedin.com/in/jrzerr
https://twitter.com/jrzerr