REST for Headless

Cut the head off and REST keeps WordPress talking: one GET for a whole site, shown in React with no rebuild step.

Cut the head off, and REST keeps WordPress talking to the front end. One route returns a whole site: menus, settings, FAQ, team and portfolio. This module builds that bridge on the 4WP Headless App plugin.

CourseWordPress REST API Course ยท Module 9 of 9 ยท Stage 3 "Ship it"
LearnAn export route, per-resource routes, a GET helper in React, fresh content on publish, what never goes into the client bundle
HowReal code from 4WP Headless App, a React front end with one plain fetch, interview questions after every lesson

One GET, a whole site

flowchart LR
  WP[("WordPress<br/>4WP Headless App")] -- "GET /wp-json/4wp/v1/export" --> FE["React front end"]
  WP -- "per-resource routes" --> FE
  ED["Publish in WordPress"] --> WP
  classDef wp fill:#ebf3fb,stroke:#61affe,color:#1e293b
  classDef fe fill:#edfcf9,stroke:#50e3c2,color:#1e293b
  class WP wp
  class FE fe

REST is one door, GraphQL is the other. The headless front end does not care which, as long as the contract holds.

Before โ†’ after

BeforeAfter Module 9
A theme rebuild for every content changepublish in WordPress, the next request shows it
Ten requests for one pageone export route
API keys in the client bundlesecrets stay on the server
REST vs GraphQL as a religionpick the door that fits the contract

You'll be able to answer

  • How would you serve a whole headless site from WordPress over REST?
  • How does a headless front end get fresh content after publishing?
  • What must never end up in a headless client bundle?