DEV Community


React SSR with PHP and WordPress

li profile image Wenchen "Neo" Li ・1 min read

I am looking for a solution that use React for the font-end and WordPress for the backend with the following requirements:

  • No static rendering at build time:
    • Was actually thinking Gatsby or React Static at first, but it requires not to re-build every time the content updates
  • No node.js middleware:
    • Cannot add a middleware to call the WordPress api and then render React
  • No classic SPA:
    • For SEO and performance considerations, we want not just a blank page coming back from the response

A potential solution we're looking at is to use Gatsby or React Static to build and then use PHP to update the generated HTML and JSON with the latest content, which isn't really an ideal solution in my opinion; so reaching out to see if there's any other solutions.

Thanks a lot!

Discussion (8)

Editor guide
rleija_ profile image
Ruben • Edited

Hmm, you’re kind of crippling yourself here because React and Nodejs play great with each other.

There are other methods to do SSR with php but I would call them kind of hacky

li profile image
Wenchen "Neo" Li Author

Thank you so much for this info!

pandasedihh profile image

Use next.js instead?

li profile image
Wenchen "Neo" Li Author

but thank you for your help!

li profile image
Wenchen "Neo" Li Author

well that's a node.js middleware if we want WordPress to be the backend...

malithmcr profile image
Malith Priyashan

May be I'm too late to reply. Next.js is a good solution. Use Wordpress Rest api with next.js.

I'm doing it here:

jdvr profile image
Juan D. Vega

If you don't want a SPA and also you don't want client side render, why would you choose react?
Have you thought about using other front-end technology?

li profile image
Wenchen "Neo" Li Author

well React is what the team is good at and used to, and I don't think we would move away from it...
and also I wouldn't say React is just for client-side SPA even though that's what a big portion of the people are using it for.
moreover, I think we are still aiming for a SPA, what I meant is just not the classic SPAs where you get a blank page as a response no matter the routes,.
but really appreciate you helping! thanks a lot!