I have a basic wordpress site at the moment, I would like to use a basic react frontend to display articles in my blog.
Can anyone tell me how I can hook the back end up to react?
Thanks
You would have to build a rest API within your wordpress site, you would then make calls to the rest api from your react app. Check here:
A very simple example from the above link:
<?php
add_action( 'rest_api_init', function () {
register_rest_route( 'route', '/author/(?P<id>\d+)', array(
'methods' => 'GET',
'callback' => 'my_awesome_func',
) );
} );
So basically you'd be able to simply integrate the rest api into your existing wordpress functions!
On your react site you'd simple use a fetch or ajax to grab the data! Checkout the fetch api here:
https://github.com/github/fetch
You could follow a tutorial, such as this one:
https://lamosty.com/2015/09/07/react-single-page-wordpress-rest-api-theme-tutorial/