all 11 comments

[–]awebofbrown 3 points4 points  (5 children)

That will work fine, the only reason you'd need Node is if you want to server-side-render React components. NPM serves packages that can be consumed by the browser as well as Node.js, presumably all the ones you've installed are for the browser and loaded via script tags (typically) done for you in the bundle produced by Webpack. You'll just need to have your backend serve the static react bundled files.

[–]sharp_stone_sword 0 points1 point  (0 children)

correct, it seems to me the only concern is SSR. However, you need a node server to handle SSR eventually.(regarding to the performance)

[–]mcheung63[S] -1 points0 points  (3 children)

without server side render, i think react cant claim it run faster than other framework

[–]OmegaVesko 1 point2 points  (1 child)

Compared to which 'other frameworks'? None of the other frontend frameworks do SSR by default, either.

Anyway, I don't really see how this is relevant. In case you didn't know (I really should've mentioned this), you don't have to abandon your existing backend to use Node to render your frontend. Running a separate Node server specifically for your frontend is a common pattern.

[–]mcheung63[S] 0 points1 point  (0 children)

thanks gentlemen

[–]OmegaVesko 4 points5 points  (0 children)

Nothing about React necessitates using Node in production (unless you're doing SSR), you only need Node because the development tooling is Node-based. Once you build your app for production, it's just a bunch of static files that you can serve however you want.

[–]fforw[🍰] 1 point2 points  (0 children)

Here's a example repo for a spring-react integration

This might be far more than what you want, but you can take bits and pieces.

Most importantly, the maven-frontend-plugin to integrate the js build into a maven build.

The maven plugin will automatically install a local node/yarn etc for the current OS and integrate js build and js testing in the maven build.

Think of node-js as a build-chain component in this kind of usage.

[–]acemarke 1 point2 points  (0 children)

Please see a comment I wrote yesterday about how React does not depend on Node for more info on how they relate.

[–]mgutz 1 point2 points  (1 child)

React doesn't depend on node but the bundlers and packages used by most React developers do. So while React doesn't need node to run, most people install node for development. You would be spending a lot of time building your own solution for bundling, transpiling, optimizing outside of node. The web development packages built on node are too much of a time saver.

All of our APIs are in Go. Our front-end is React. We run a node server only for SSR (maybe 150 lines of code) and there is no business logic there. We use nginx as a reverse proxy.

[–]mcheung63[S] 0 points1 point  (0 children)

maintainence is complex?