It’s no secret that all of the new screens in the WordPress dashboard are powered by React/JavaScript. Updating posts or settings used to require the entire dashboard to save and reload, but inside the site editor, WordPress functions like a single page application. So how does it save changes and fetch new data?
Well, everything you can do in PHP with classes like WP_Query or functions like wp_update_post, you can do with JavaScript and the WordPress REST API. The REST API is the de facto way for interacting with WordPress once you’re inside the React world. If you’re building custom blocks, custom admin screens, or even extra settings to core blocks, there’s a good chance you’ll be using the REST API.
Now technically, WordPress has an entire “data layer” package to handle a lot of this once you’re inside React, but before you dig into the data layer, I think it’s important to just understand the REST API itself, how it differs from the it’s PHP counterparts, and how you can create your own endpoints and extend WordPress itself..
If you have any questions, add them in the YouTube comments. And feel free to share this video- and hopefully this whole series- with anyone you think would want it.
Leave a Reply