React / Headless WP Possible?

I’ve been reading a lot about React and using it as a front-end for WordPress using WordPress’s REST API. Is this possible in Local, and if so, does anyone have step-by-step instructions on how to do it in Local? I’d love to replace PHP with React, at least on the front-end.


1 Like

Sure it’s possible!

Step 1.
Build a site with React

Step 2.
Add your data to wordpress

Step 3.
Using XHTTPRequest call the api endpoints before you mount the components.

Step 4. (optional)
Create a theme, place your tools and source code inside.

Both technologies are independent from each other and can live together in the same folder. NONE of these are related to Local by Flywheel or even WordPress it all comes down to you being able to create a website with React and using ajax to call the REST API (which could be in Local). Although building a site this way is very unconventional and probably not for the reason you think, it’s still interesting and you could learn a lot this way.


OK so what i am wondering is can you load up all the build tools into the local folders so you can run npx create-react-app myapp and have it create a local directory called myapp what you can then dev your site front end in and then run npm run build to create the build folder then move the build folder contents to the root of the local wp so that is the index.html file that runs and displays when localhost is called?