How to use react.js with a multi page website (Non SPA)? How to use react.js with a multi page website (Non SPA)? reactjs reactjs

How to use react.js with a multi page website (Non SPA)?


Here are my opinions:

  • You should bundle React and all your code in all pages that will have any part rendered by React components (From what I gather, /admin/entity).
  • Your React component should always be rendered to a specific element (e.g., an empty <div>) and should have something like a React Router configured so that it ignores /admin/entity but renders /admin/entity/:id. Your challenge is that any links that point to a different :id URL should optimally be inside the React components, using Link components. This will hook up your router automatically.

Your routes will probably look like this:

<Route path="admin/entity/:id" handler={Entity} />

I believe that, when you run the Router, if the browser's URL isn't in the expected format, React won't actually render anything.