8

We are setting an app using Laravel in backend and React.JS + Redux in front end. So looking for solution for server side rendering (for SEO).

Found this solution: https://github.com/tz5514/Laravel-Redux-Isomorphic but it seems like in backend it using express.js to render.

So I am searching for any better server side rendering solution.

3 Answers 3

13

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.

I got this answer from HashNode

Sign up to request clarification or add additional context in comments.

4 Comments

But, how do you deal with this? do you have two servers?
Yes currently using two different servers for this.
Why would you need two servers you can have laravel and nodejs on the same server on different ports.
applauding to the one who explained the logic behind building a modern web.
9

you can use the spatie/laravel-server-side-rendering package, it is great for both React & Vue. Here you can find YT tutorial for this package usage as well - https://youtu.be/uO42Kpa4pvI

1 Comment

Does lazy-loading/split chunks work for you with spatie/laravel-ssr?
0

React seems suitable with Node Js (only). But, You can try to solve your problem with use this Laravel Plugin. react-laravel

2 Comments

We saw this package but it doesnt have proper support for redux.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.