Server-side routing with react-router

Let’s set up server-side routing with react-router for a universal web application.

Prerequisites

Nodemon

$ npm install nodemon -g
$ nodemon --ext js,jsx
$ nodemon --ext js,jsx --ignore public/ --ignore client.js

ReactRouter

$ npm install react-router@3
$ mkdir routes/
server.js
routes/index.jsx
routes/index.jsx
if (error) {
response.status(500).send(error.message);
}
if (redirectLocation) {
response.redirect(302,
redirectLocation.pathname + redirectLocation.search
);
}

Passing Props in ReactRouter

routes/index.jsx

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store