rockiger / reactpress

Plugin that lets you easily create, build and deploy React apps into your existing WordPress sites.
https://rockiger.com/en/reactpress/
GNU General Public License v2.0
50 stars 6 forks source link

Server side rendering question #36

Closed wlaurance closed 1 year ago

wlaurance commented 1 year ago

Hey @rockiger,

I was wondering if you have any plans to support server side rendering?

My main use case is using React-Helmet to insert an Schema.org product/recipe into the DOM. The particular importer i'm using only supports the schema if it's written in the returned HTML from the server.

Have you given any thought to this on how it might be implemented?

rockiger commented 1 year ago

I don't have any plans to support SSR at the moment. I wonder if it makes sense for a WordPress site (which is SSR) to have another SSR website embedded. Why not use WordPress for this content? ReactPress is meant to have a single page application inside a WordPress site.

And I don't have any idea how the routing would work because the routing of all your SSR pages would need to take place in WordPress.

Wouldn't it be better for you to use a headless WordPress approach?

PS: If I misunderstood you, and you only want to use React-Helmet. It should work perfectly.

wlaurance commented 1 year ago

The main reason I'm not using wordpress, is that I'm not much of a wordpress dev which is what gravitated me to your plugin in the first place 😄

You are totally right that this would probably be best served by PHP/wordpress to return all of the elements.

React-helmet does work great if the client (think Google Bot/ SEO bot) runs Javascript. The meta description, title, scripts, and anything inserted into <head> at JS runtime works perfect. Just not for a client that doesn't run JS. specifically Instacart Tastemakers only pulls html and doesn't scrap the webpage with JS runtime. https://www.instacart.com/affiliate-home

I think this is definitely an edge case and outside of the scope of the intended use of the plugin you've written so far.

This isn't an urgent thing for me so I don't think I'll put much more thought into it. Thanks for the info! :)

rockiger commented 1 year ago

I am glad ReactPress attracted you as a React dev ;) Theoretically you could use ReacPress with React-Snap. React-Snap would go through all routes and pre-render them.

Having said that, did you consider using WordPress as a headless CMS with something like Nextjs? Then you would be free of PHP and could use React-Helmet (although Next has its on solution for injecting content into the head).

Headless WordPress + Nextjs is less complex than using standard WordPress + React app embedded with ReactPress + react-snap. Both solutions would enable you to create full Websites without knowing PHP.