Full Stack Development 4 min read

WordPress REST API: Building Headless WordPress with React

WordPress REST API: Building Headless WordPress with React

What is headless WordPress?

Headless WordPress means using WordPress only as a content backend. The frontend is built separately in a modern framework — React or Next.js — and consumes content via the REST API or GraphQL. WordPress handles content storage and editorial workflow. The frontend renders however you want.

The architecture is gaining ground in 2026, but it is not the right answer for every project. The article below is the framework I use when clients ask whether to go headless.

When does headless WordPress make sense?

Multi-platform content. If the same content needs to feed a website, a mobile app, and possibly a third surface (a TV app, a widget, a partner integration), headless is ideal. One source of truth, many frontends. The AzanGuru learning platform was built exactly this way: a WordPress backend serves a Next.js website and a React Native mobile app through a GraphQL API. Both surfaces stay in sync because there is only one place content lives.

Complex interactive UIs. When the frontend needs heavy state management, real-time updates, or app-like interactions that traditional WordPress would render awkwardly.

Performance at global scale. Statically generated pages from Next.js SSG, served from a CDN, hit any visitor in any region in under 100ms. The WordPress backend can be in any single region without performance penalty for visitors.

Frontend-strong teams. If the team's strength is React and TypeScript rather than PHP, headless lets them work in their preferred stack while editors still get the WordPress admin.

When should you stick with traditional WordPress?

Content-focused sites. Blogs, news sites, content-heavy businesses benefit from the WordPress theme system and plugin ecosystem. Going headless means rebuilding functionality that themes provide for free.

Limited budget. Headless is two applications to build and maintain. That costs more.

SEO-dependent sites with simple structure. Next.js handles SEO well, but a well-built WordPress theme plus an SEO plugin (Yoast, RankMath) covers most needs with less complexity.

Plugin-dependent sites. If you rely on WooCommerce, membership plugins, form plugins, or page builders that render frontend output, going headless means reimplementing each of those.

How do you set up the WordPress REST API?

WordPress ships with a REST API enabled by default. Every post, page, category, tag, and custom post type is reachable.

Default endpoints:

  • Posts: /wp-json/wp/v2/posts
  • Pages: /wp-json/wp/v2/pages
  • Categories: /wp-json/wp/v2/categories
  • Media: /wp-json/wp/v2/media
  • Custom post types: /wp-json/wp/v2/{post-type}

The default response often is not enough. I register custom REST fields with register_rest_field() to expose ACF fields, computed values, and full featured-image URLs directly — saving an extra round trip per post.

How do you fetch data in Next.js?

Next.js gives three rendering strategies. Picking the right one is half the work.

Static Generation (SSG, getStaticProps). Best for content that does not change minute-to-minute. Blog posts, portfolio pages, informational pages. Pages are generated at build time, served from a CDN, and load near-instantly. With Incremental Static Regeneration (ISR) you can revalidate periodically so content stays fresh without a full rebuild.

Server-Side Rendering (SSR, getServerSideProps). Best for content that changes per-request or per-user. Search results, filtered listings, dashboards.

Client-Side Rendering. Best for interactive features that do not need SEO — admin dashboards, forms, real-time UIs. Fetch in useEffect or with React Query or SWR.

Is GraphQL better than REST for headless WordPress?

If the REST API feels restrictive, WPGraphQL exposes a typed GraphQL endpoint over WordPress content. The advantages are real:

  • Fetch exactly the fields you need; no over-fetching.
  • Get related data in a single query (post + author + categories + featured image).
  • Strongly typed schema you can introspect.
  • Excellent developer experience via GraphiQL.

On AzanGuru, WPGraphQL replaced what would have been 4-5 REST calls per page with a single query. On a list view, that is the difference between snappy and sluggish.

What problems does headless introduce?

Preview. Editors expect to preview drafts before publishing. With headless that means a preview route in Next.js that fetches draft content via the API with a preview token.

Menus. WordPress menus are not in core REST by default. Use a plugin like WP REST API Menus, or register a custom endpoint.

Forms. Contact forms, search, and other interactive features need custom implementations because WordPress form plugins do not render on a non-WordPress frontend.

Authentication. For protected content you need JWT or WordPress application passwords. Both are fine, just decisions to make early.

My production headless stack

For projects where headless is the right choice, this is the setup I reach for:

  • Backend: WordPress + ACF Pro + WPGraphQL + custom endpoints
  • Frontend: Next.js + TypeScript + Tailwind CSS
  • Data: GraphQL via Apollo Client or urql
  • Deployment: frontend on Vercel, WordPress on a managed VPS
  • Sync: ISR with on-demand revalidation triggered by WordPress webhooks

That stack gave AzanGuru a CMS its editors love, a frontend that ranks, and a single API powering the React Native mobile app too.

Want to go headless?

Headless WordPress is powerful and complex. If you are evaluating it for a project, get in touch — we can scope whether it is the right call before any code is written.

Written by Sungraiz Faryad

Full Stack Developer with 13+ years building enterprise WordPress solutions, web applications, and custom plugins. Currently available for freelance projects.

Hire Me

Need Help With This?
Let's Work Together

If you're facing challenges like those discussed in this article, I can help. 13+ years of experience, 100+ projects delivered.

Get in Touch