loading...

How to Use WordPress with React to Build a Modern Web App

couellet profile image Charles Ouellet Originally published at snipcart.com on ・2 min read

Strapping React.js on a WordPress Backend: WP REST API Example

When we first wrote about using WordPress as a headless CMS and the WP REST API back in 2017, it was a very big deal for us, JAMstack aficionados.

I mean, a concept like “headless CMS” was only beginning to make noise, and WordPress embracing it was a huge statement.

And it paid.

The web development landscape is ever-changing and the promises of modern frontend techs are materializing.

wordpress-rest-api

Every developer and their dog have something to say about WordPress, and it's not always flattering. Far from it. However, even its most avid detractors are forced to take notice of this feature, because it has already transformed the way we use the popular CMS.

WordPress REST API is a huge step forward for frontend developers looking to combine the power of JavaScript frameworks like React (or Vue.js) with WordPress.

This is exactly what I want to do today with this demo of the WordPress REST API in the work.

I'll use WordPress as a backend, and the REST API to feed data into a React app.

More precisely, you’ll learn how to:

  • Access the WP REST API from your frontend
  • Add a custom post type and expose it to the API
  • Build a React app backed by this API
  • Handle React Hooks (and create a custom one)

Before we start, let's see what is the REST API for WordPress and why you should care about it.

What is WordPress REST API?

WordPress itself doesn't need any introduction, but let's take a closer look at the recent WP REST API.

Read the rest of this post & technical tutorial here

Discussion

pic
Editor guide