The <StaticRouter> component is part of the react-router-dom package (uses <StaticRouter> definition in react-router), and it's used in rendering React-Router components on the server-side. The <StaticRouter> component is similar to the other Router components, as it accepts only one child component—the React application's root component (<App />). This component should be used in a stateless application, where the user is not clicking around to navigate to different sections of the page.
Let's include the <StaticRouter> component by wrapping the application's root component:
import { StaticRouter } from 'react-router-dom';
app.get('*', (req, res) => {
const context = {};
const reactMarkup = ReactDOMServer.renderToString(
<StaticRouter...