Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React.js server side rendering with PHP

Tags:

I would like to develop themes/plugins for WordPress based on React. To make it search engine friendly, I need it to be rendered initially on the server (serverside-rendering).

The only way to do this, as far as I know, is to use react-php-v8js, which requires the PECL V8js extension. This is a problem since I have no control over the platform on which these themes/plugins will be run.

Is there a way to make React and WordPress work together without having to install additional extensions? Perhaps by building/compiling React files into PHP?

like image 301
Yoav Kadosh Avatar asked Jan 03 '16 03:01

Yoav Kadosh


People also ask

Does PHP do server-side rendering?

Until recently, the JavaScript programming language was used solely for rendering client-side pages, while server-side rendering relied on PHP. Today, newbie frameworks like Angular. js and React.

Can Reactjs be used with PHP?

Now can we use React js with Php ? Yes. This is possible. Reactjs is just the 'V' in MVC.

Can react js be a server-side rendering application?

Yes! This is where server-side rendering for React comes in. In this article, I want to introduce you to server-side rending (SSR) with React, reasons to use it, and some popular frameworks for rendering React on the server side.

Can we use laravel With React?

It's still possible and very straightforward to set up Vue or React with a Laravel project. In this article, I'll walk you through the process of bootstrapping a brand new Laravel project and integrating React with it so all Laravel developers, as well as React.


1 Answers

There's an article that describes how to do this:

https://sebastiandedeyne.com/server-side-rendering-javascript-from-php/

But it's a fairly complex setup and it requires using composer. That can be difficult in Wordpress projects since Wordpress tends to completely eschew the modern php architecture.

If you're looking for a library to help with SSR in PHP:

https://github.com/spatie/server-side-rendering

Best of luck on it.

like image 117
Michael Ryan Soileau Avatar answered Sep 20 '22 18:09

Michael Ryan Soileau