DEV Community

Discussion on: What was your win this week?

Collapse
 
michaelcurrin profile image
Michael Currin

I bought a monitor which can swivel ↩️

And finally cracked SSR with React

GitHub logo MichaelCurrin / react-ssr-quickstart

Starter template for server-side and client-side rendering of a React app ⚛️ 📦

React SSR Quickstart ⚛️ 📦

Starter template for server-side and client-side rendering of a React app

GitHub tag License

Made with Node.js Package - react Package - express

Preview

Sample screenshot

Use this project

Use this template

About

Background

Based on tutorial:

We set up a client-side React app with some components including an incrementing counter.

On initial page load without JS running, a user or a search engine crawler will see an empty page. So we add a server-side Express app that return an HTML page which acts as a fully-rendered starting point that needs no JS to view in the browser.

We do this by calling ReactDOMServer.renderToString, which unfortunately freezes the app so that ignores user interaction. This is solved by calling React.hydrate on the client, so that the browser can make the initial HTML and turn it into a dynamic app in the usual SPA style.

The…