After using React a bit in the Repl.it environment, I have decided to use an Express-React app. The React rendering and hosting style is foreign to me, so I do not understand how to merge that with an Express app. How would I do so?
Took me a while to figure this out, but here's a template you can use: https://repl.it/@timmy_i_chen/react-express-template (kudos to nathandalal, whom i had the pleasure of working with last year)
Basically, you use webpack to compile the client (written in react) into a single
bundle.js file, which you serve to your users. The express server works as you'd expect, serving static files + the bundle.js file.
Note that when using my template when making changes to the client you won't need to restart the server (but you will need to refresh the preview window after a second when it rebuilds). Webpack is run with the
--watch flag which will re-bundle everything after any files are changed.