Displaying a server side rendered reactJS component within a PHP application

喜欢而已 提交于 2019-12-06 16:40:13

Stoyan Stefanov created a library for calling into the V8 JS library from PHP code for doing this sort of thing; it's available here:

https://github.com/reactjs/react-php-v8js

You can read about how he set up React server rendering in these two posts:

http://www.phpied.com/server-side-react-with-php/
http://www.phpied.com/server-side-react-with-php-part-2/

Rendering won't be instant, but it should be reasonably fast. If you're having performance problems and caching doesn't help, you can consider using Google's AJAX crawling feature in order to use server rendering only for Googlebot but not normal requests:

https://developers.google.com/webmasters/ajax-crawling/docs/getting-started

Note that browsers will also take advantage of server-rendered markup so even if the initial request is slower, rendering may be faster.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!