I posted just 2 months ago about Foxhound and how I found it pretty cool, but also curious that it was one of very few themes around that combine the WordPress JSON API and React, even though they seem like a perfect natural fit. Like a headless CMS, almost.
Since then, a few more things have crossed my desk of people doing more with this idea and combination.
Maxime Laboissonniere wrote Strapping React.js on a WordPress Backend: WP REST API Example:
I’ll use WordPress as a backend, and WordPress REST API to feed data into a simple React e-commerce SPA:
- Creating products with the WP Advanced Custom Fields plugin
- Mapping custom fields to JSON payload
- Consuming the JSON REST API with React
- Rendering products in our store
Perhaps more directly usable, Postlight have put out a Starter Kit. Gina Trapani:
People who publish on the web love WordPress. Engineers love React. With some research, configuration, and trial and error, you can have both — but we’d like to save you the work.
Another example: Alex MacArthur’s WP Vue.
One of the sweetest things about WordPress is the automatic json feed. It’s so handy!
Gatsby, a React static-site generator, has a really great plugin for WordPress. They have a few posts on their blog about using it if you’re interested in reading more: https://www.gatsbyjs.org/blog/2017-10-05-portfolio-site-gatsby-wordpress/
I had a poke around Foxhound too. In the end I went with using WordPress simply as a backend for a couple mini web apps built in React:
Daily design newsreader
Prototyping tool comparison site
Both React Apps just read and display from my WordPress site, making use of custom fields. There are a couple great plugins that have helped me do this:
WP REST API Controller for exposing custom fields and taxonomies
WP REST API Cache to speed things up
If anyone’s interested, I’ll look at open sourcing to github