PHP and React on Server side render

8.3k Views Asked by At

I am still new programmer but I have an idea about project. I think about architecture for now. So my question is "Which is the best way to use react on server side render in PHP backend". I have researched and I`ve found two decision about that.

====================================================

First is to use React.js SSR with a Node.js service.

Advantages:

  1. Easy to install and update

  2. Standart enviorment for running react.js

Disadvantages:

  1. Maintain separate server

====================================================

Second is to use React.js SSR with PHP`s V8Js.

Advantages:

  1. Write js in PHP.

Disadvantages:

  1. Complicate install and update process

  2. Maybe V8Js is not scalable

I also find "react-php-v8js" library but maybe it`s still experimental. I want to know:

  1. Is there any other ways to render React.js in PHP?

  2. Which way gives better performance?

  3. Which way is better in production?

  4. What do you think about SSR React.js with PHP?

My backend will be in PHP. And I will use custom framework if it does matter. :)

2

There are 2 best solutions below

7
Josep Vidal On

You are making it too complicated.

Just make a backend with PHP and an API REST.

Then you can create a frontend with pure React that just comunicates with the backend through fetchs to the API.

0
Vyas Reddy On

You can add react js as script tags in existing website https://reactjs.org/docs/add-react-to-a-website.html