@agilius
React/Nodejs Developer
UX enthusiast
Coffee addict
Startup founder wannabe
Nothing here yet.
No blogs yet.
It's very hard to estimate how this will impact your server. A wild guess in this case would be this: Two languages for the server, one with apache, one with nginx or something like that will probably be harder to manage and optimise than just one language, with one server. So Nodejs should be the way to go if you want the smoothes experience. You could however take into consideration splitting the two apps on separate servers, and also how many developers you have that know laravel more than nodejs. In the end, the backend is just a api, so it really doesn't matter on what server it lives on, and what language it uses. I worked with a project that had a nodejs backend api, and now on one with java for the backend. It makes no difference what so ever for the nodejs app.
Other viable ways of figuring it out are: checking for the process.env variable which is node specific having a webpack environment variable and using that. This way when you bundle the application for the clientside the build system automatically strips away code used for the server, resulting in a smaller bundle size.
React is javascript, so it needs a javascript engine in order to run, so one way to see a laravel project is to think of it as the 'backend' api server, which is completely separated from the 'frontend' server which uses node to run the javascript part of the application. In other words, you have two apps, the one with laravel that exposes an api which could be used by any other service in the infrastructure, and the reactjs app which is a nodejs app that consumes that api, and handles the magic of react + redux. The way your site is actually accessed from the outside world is thru the express/nodejs app, which calls the laravel api for data persistence and other business logic. The laravel app handles sessions, oauth, the database, file access to the hardrive and so on, while the nodejs app handles the actual website routing, the templates, the css and javascript part.