WordPress Logo – Athemeart WordPress Themes

WordPress as a Headless CMS: A Backend-Only Guide

Headless WordPress keeps the editor your team already knows and throws away the part that slows most modern projects down: the PHP theme. WordPress stores and manages the content, an API hands that content out as JSON, and a separate frontend built with Next.js, React, Astro or a mobile app decides how it looks. That is the whole idea of a headless CMS, and WordPress, which still runs a little under 58% of every site with a known CMS, is one of the most practical backends you can choose for it.

This guide is written for developers, agencies and technical site owners who want more than a definition. You will get the architecture, a fair look at traditional vs headless WordPress, a seven-step headless WordPress setup, working code for the WordPress REST API and WPGraphQL, framework examples for Next.js, React and Astro, and the SEO, security and troubleshooting work that most tutorials skip. Every code block below was written for WordPress 7.0, Next.js 16 and Astro 6, the current major versions in December 2026.

Quick answer: WordPress becomes a headless CMS when you stop using its theme to render pages and instead read its content through /wp-json/ (REST API) or /graphql (WPGraphQL) from a separate frontend. It is a strong choice for content-heavy sites that need speed, multiple channels or a custom JavaScript frontend. It is the wrong choice for small brochure sites that depend on page builders and plugins that output HTML.

1. What Is Headless WordPress? Understanding the Backend-Only CMS

What does headless CMS mean?

A headless CMS is a content management system with no built-in presentation layer. The “head” is the part visitors see: templates, HTML, CSS. Cut it off and what remains is the “body”: a database, an editing interface, user roles, media handling and an API. Content is written once, stored as structured data and delivered to any “head” that asks for it, whether that is a website, an iOS app, a smart display or an AI assistant that reads your product catalog.

Purpose-built headless platforms such as Contentful, Sanity and Strapi were designed this way from day one. WordPress was not, but since the REST API landed in core in version 4.7, it has been able to work in exactly the same way.

How WordPress works as a headless CMS

In a normal install, WordPress receives a request, runs a PHP theme, queries MySQL and returns a finished HTML page. In WordPress as a headless CMS, the theme stops mattering. Editors still log in to /wp-admin, still write in the block editor and still upload media. The difference is who reads that content: a separate application calls the WordPress API, receives JSON and renders the page itself.

That is why people describe it as a WordPress backend-only CMS or WordPress without a frontend. The public never touches WordPress directly. Only your frontend, and your editors, do.

What is decoupled WordPress architecture?

You will see “headless” and “decoupled” used as synonyms, and most of the time that is fine. Strictly speaking there is a small difference:

  • Headless WordPress: WordPress renders nothing public. The theme is disabled or redirected, and 100% of pages come from the external frontend.
  • Decoupled WordPress: WordPress and the frontend are separate systems, but WordPress may still render some things, such as previews, a legacy section or the checkout.
  • Hybrid WordPress: the WordPress theme renders most pages while a JavaScript app handles one interactive area (a product configurator, a dashboard). This is “progressive decoupling”.

The setup in this guide is fully headless, because that is what “backend-only” means, but every technique also works for a decoupled or hybrid build.

How content is delivered through APIs

WordPress exposes content through two main channels:

  1. The WordPress REST API, built into core. Every site already has it at https://your-site.com/wp-json/. Posts live at /wp-json/wp/v2/posts, pages at /wp/v2/pages, media at /wp/v2/media, and so on.
  2. WPGraphQL, a free plugin that adds a single /graphql endpoint where the frontend asks for exactly the fields it needs in one request. It is now a canonical plugin on WordPress.org, supported by Automattic.

The frontend sends an HTTP request, WordPress answers with JSON, and the frontend turns that JSON into HTML at build time, on the server, or in the browser. Here is what a real REST response looks like.

Screenshot: WordPress REST API JSON response in a browserA browser window open at cms.example.com/wp-json/wp/v2/posts showing a JSON array with id, date, slug, status, title and featured_media fields.πŸ”’ cms.example.com/wp-json/wp/v2/posts?per_page=1JSONRaw DataHeaders200 OKβ–Ύ 0:id128date“2026-11-28T09:14:00”slug“wordpress-as-a-headless-cms”status“publish”β–Ύ title:rendered“WordPress as a Headless CMS”β–Έ content:{…}β–Έ excerpt:{…}featured_media311β–Έ categories:[ 7 ]β–Έ _links:{…}What the frontend readstitle.rendered β†’ <h1>slug β†’ URL /blog/[slug]featured_media β†’ image lookupIllustration of a WordPress REST API response as shown in Firefox’s JSON viewer
Every WordPress site already serves JSON like this at /wp-json/wp/v2/posts. A headless frontend only needs this data, not the theme.

2. Traditional WordPress vs. Headless WordPress: What’s the Difference?

Traditional WordPress architecture

Traditional (or “monolithic”) WordPress does everything in one place. The same server stores the content, runs the PHP theme, executes plugins, builds the HTML and sends it to the browser. A page builder, a contact form plugin and an SEO plugin all hook straight into the page output. It is simple, cheap and supported by tens of thousands of themes and plugins. The trade-off is that the frontend is tied to PHP and to whatever markup those plugins print.

Headless WordPress architecture

In headless WordPress architecture, responsibilities split into two applications that live on different servers and often different domains: cms.example.com runs WordPress, and www.example.com runs the frontend. They only talk over HTTPS through the API. Each one can be deployed, scaled and secured independently.

Traditional WordPress vs headless WordPress diagramLeft: one WordPress server handles database, PHP theme and HTML output. Right: WordPress backend sends JSON through an API to a separate frontend on a CDN, which serves HTML to visitors.Traditional WordPressHeadless WordPressOne WordPress serverMySQL database + wp-adminPlugins + PHP themeHTML built on every requestTightly coupled: content = presentationWebsite visitorWordPress backendcms.example.comwp-admin Β· editorMySQL Β· mediano public themeFrontend appwww.example.comNext.js / AstroReact componentspre-built on CDNJSONREST API /wp-json/ or WPGraphQL /graphqlthe only bridge between the two systemsWebsite visitorEditors only ↑
Traditional WordPress builds HTML on the same server that stores content. Headless WordPress separates the two and connects them through an API.

Key differences in functionality and performance

Factor Traditional WordPress Headless WordPress
Rendering PHP theme on every request (unless page-cached) Static, server or edge rendering in a JavaScript framework
Frontend stack PHP, theme templates, page builders Next.js, React, Astro, Vue, Svelte, native mobile
Plugins that change the frontend Work out of the box Mostly need rebuilding (forms, sliders, builders)
Performance ceiling Good with caching, limited by PHP + database Very high: pre-built HTML served from a CDN
Channels One website Website, apps, kiosks, email, AI agents from one source
Security surface Public login, theme, plugins all exposed Backend can be hidden, frontend has no database
Live preview Built in Must be configured (draft mode + authentication)
Hosting One server Two environments: WordPress + frontend hosting
Team skills WordPress/PHP generalist WordPress + JavaScript developers
Typical build cost Lower Higher (roughly 1.5Γ— to 3Γ— for custom work)

When should you choose a headless approach?

Choose headless when the frontend is the competitive advantage: you need a JavaScript-first experience, you publish the same content to several channels, your traffic is heavy or spiky, or your developers simply work faster in React than in PHP templates. Stay traditional when your editors depend on visual page builders, your budget is small, or nobody on the team will own a second codebase. Section 12 turns this into a full decision guide.

3. How Does Headless WordPress Architecture Work?

A production WordPress decoupled architecture has four layers. Understanding each one makes every later decision, from caching to SEO, much easier.

Headless WordPress architecture diagram with four layersLayer 1 content: WordPress, ACF and media. Layer 2 API: REST API and WPGraphQL. Layer 3 rendering: Next.js, Astro and React builds. Layer 4 delivery: CDN serving web, mobile app, smart devices and AI assistants. A webhook from WordPress triggers revalidation in the rendering layer.Headless WordPress Architecture: 4 LayersLAYER 1 Β· CONTENTWordPressBlock editorCustom post typesACF fieldsMedia libraryUsers + rolesSEO plugin dataLAYER 2 Β· APIREST API/wp-json/wp/v2/built into coreWPGraphQL/graphqlcanonical pluginJSON over HTTPSLAYER 3 Β· RENDERINGNext.js 16SSG Β· SSR Β· ISRAstro 6static + islandsReact SPAclient-sideNative appsReact Native Β· SwiftLAYER 4 Β· DELIVERYGlobal CDN / edge🌐 WebsiteπŸ“± Mobile appπŸ“Ί Smart screensπŸ€– AI assistantspublish/update β†’ webhook β†’ revalidate cached pages
Content, API, rendering and delivery are separate layers. A publish webhook keeps the rendered pages in sync with WordPress.

WordPress as the backend content management system

Layer one is plain WordPress. It keeps doing what it is best at: a mature editor, revisions, scheduled publishing, multilingual plugins, user roles and a media library. Your job is to make the content structured. Instead of one huge block of HTML per page, you model content with custom post types, taxonomies and custom fields so the frontend receives clean data (“price”, “author bio”, “hero image”) rather than markup it has to scrape.

REST API vs. WPGraphQL

Layer two is the bridge. The WordPress REST API ships with core, has one URL per resource and works with any HTTP client. WordPress GraphQL via WPGraphQL gives you one endpoint and a typed schema, so a single query can fetch a post, its image, its categories and its author together. Both are free and both are production-ready. Section 8 compares them in depth.

Connecting a separate frontend

Layer three is your application. It only needs one piece of configuration to talk to WordPress: the API base URL (and, for private content, credentials). Most teams keep these in environment variables so the same code can point at a staging or production CMS.

# .env.local (Next.js)
WORDPRESS_API_URL=https://cms.example.com/wp-json
WORDPRESS_GRAPHQL_URL=https://cms.example.com/graphql
REVALIDATE_SECRET=change-me-to-a-long-random-string

# wp-config.php (WordPress)
# define( 'HEADLESS_REVALIDATE_SECRET', 'change-me-to-a-long-random-string' );

How frontend applications retrieve WordPress content

There are three rendering strategies, and most real projects mix them:

  • Static site generation (SSG): pages are built once from API data and served as plain HTML from a CDN. Fastest and cheapest to serve, but a rebuild is needed when content changes.
  • Server-side rendering (SSR): the frontend calls WordPress on every request. Always fresh, but every visit hits your API.
  • Incremental or on-demand revalidation (ISR): pages are cached like static pages, then rebuilt in the background on a timer or when WordPress sends a webhook. This is the sweet spot for most headless WordPress sites, and Next.js 16’s Cache Components model builds on exactly this idea.

Layer four, delivery, is the CDN or edge network that serves the result to browsers, apps and anything else that consumes your content.

4. Benefits and Drawbacks of Using WordPress as a Headless CMS

Headless is not “better WordPress”. It is a different set of trade-offs. Market demand shows why so many teams are weighing them: analysts at Mordor Intelligence estimate the headless CMS software market at about $1.82 billion in 2026, rising to $4.42 billion by 2031.

Headless CMS statistics 2026 chartBar chart of headless CMS software market size: 1.56 billion dollars in 2025, 1.82 billion in 2026 and 4.42 billion forecast for 2031. Second chart: organizations using headless architecture rose from 59 percent in 2021 to 73 percent.Headless CMS by the numbers (2026)Market size in USD billions (Mordor Intelligence) and share of organizations using headless (WP Engine survey)012345$1.56B$1.82B$4.42B202520262031 (forecast)β‰ˆ19.4% compound annual growth, 2026–2031Organizations using headless202159%Today73%WordPress share of siteswith a known CMS (Nov 2026)57.9%Source: W3Techs via Search Engine Journal
Demand for headless content management keeps growing, and WordPress remains the most widely used CMS that can serve as a headless backend.

Greater frontend flexibility

The frontend is no longer limited to PHP templates and theme hooks. Your developers can use any framework, any component library, any CSS approach and any design system. Rebuilding the site design in two years no longer means migrating the CMS; you replace only the frontend and keep every post, page and media file where it is.

Improved performance and scalability potential

When pages are pre-rendered and served from a CDN, a traffic spike hits cached HTML, not your database. WordPress only has to answer API calls when content changes or a cache expires. That is the main reason media sites and stores with flash sales move to headless. Note the word potential: a badly built React frontend that ships a megabyte of JavaScript can easily be slower than a well-cached classic theme with Redis object cache enabled.

Omnichannel content delivery

Write a product description once and publish it to the website, the iOS app, an in-store screen and a newsletter. Because the content is plain JSON, every channel reads the same source of truth. This “create once, publish everywhere” model is the original reason headless CMS platforms exist.

Enhanced frontend development freedom

Frontend teams get Git-based workflows, preview deployments for every pull request, TypeScript, component testing and modern tooling. Backend teams keep WordPress and its ecosystem. If your developers are following a modern frontend developer roadmap, headless WordPress lets them use those skills without abandoning the CMS your editors love.

SEO and plugin compatibility challenges

This is the biggest catch. Any plugin that prints HTML into a theme stops working on the public site: page builders like Elementor and Divi, slider and gallery plugins, most form plugins, cookie banners and the frontend half of SEO plugins. The data side of plugins (custom fields, SEO metadata, translations, WooCommerce products) keeps working through the API, but someone has to rebuild the output in the frontend. Section 9 shows how to do that for SEO.

Higher development and maintenance complexity

You now run two applications, two hosting bills, two deployment pipelines and two sets of updates. Previews, redirects, sitemaps, search and form handling all need deliberate work. Budget for it before you commit.

Benefits of headless WordPress Drawbacks of headless WordPress
Any frontend framework or device Frontend plugins and page builders stop working
CDN-level speed and easy scaling Two codebases and two hosting environments
One content source for many channels Previews must be built and secured
Smaller public attack surface SEO output must be recreated in the frontend
Redesigns without CMS migration Higher initial cost and JavaScript skills needed

5. What Do You Need to Build a Headless WordPress Website?

A WordPress installation and hosting

Any up-to-date WordPress install works. In practice you want PHP 8.2 or later, HTTPS, pretty permalinks and a host that does not strip the Authorization header (that one bites people; see section 11). Because the backend only serves editors and API calls, it does not need to be a large server, but it should be fast at answering uncached API requests. If you are moving an existing site onto a dedicated CMS subdomain, follow a proper checklist for migrating WordPress to a new host so nothing breaks in transit.

REST API or WPGraphQL

The REST API is already there. WPGraphQL is a one-click install from the plugin directory. Many teams add both: REST for simple calls and integrations, GraphQL for complex, nested page data.

Frontend framework (Next.js, React, or Astro)

  • Next.js 16: the most common choice for headless WordPress with Next.js. It supports static, server and revalidated rendering in one app, and its Cache Components model is now the recommended approach for every app as of version 16.4.
  • Astro 6: ideal for content-heavy sites that need very little JavaScript. Version 6 made Live Content Collections stable, so you can fetch CMS content at request time without a rebuild.
  • React (Vite) or React Native: best for app-like dashboards or mobile apps where SEO is not the main goal.
  • Others: Nuxt (Vue), SvelteKit, Remix and Faust.js (a WordPress-focused Next.js toolkit) all work the same way.

Development environment and API testing tools

  • A local WordPress (LocalWP, wp-env, DDEV or Docker) plus Node.js 22 for the frontend.
  • An API client such as Postman, Insomnia, Bruno or plain curl.
  • The GraphiQL IDE that ships with WPGraphQL, for exploring the schema.
  • A JSON formatter to read long API responses quickly.
  • WP-CLI for scripting installs, users and options.

Hosting for the frontend application

The frontend needs a Node.js or edge-capable host: Vercel, Netlify, Cloudflare Pages, AWS Amplify, or your own VPS running Node behind Nginx. Pure static Astro builds can go on any static host. Several WordPress hosts now sell bundled “WordPress + Node” plans for headless builds.

6. How to Set Up WordPress as a Backend-Only CMS

Here is the complete headless WordPress setup, from a fresh install to content showing up in your frontend.

Step 1: Install and configure WordPress

Install WordPress on its own subdomain (for example cms.example.com) so the public domain is free for the frontend. Set permalinks to anything except “Plain”; the REST API’s pretty /wp-json/ routes depend on rewrite rules. Then tell search engines to ignore the backend, because the frontend is the site you want ranked. With WP-CLI, the whole step takes about a minute:

# Install WordPress + the headless essentials with WP-CLI
wp core download
wp config create --dbname=headless_db --dbuser=wpuser --dbpass='strong-password'
wp core install --url=https://cms.example.com --title="Headless CMS" \
  --admin_user=editor-admin --admin_email=you@example.com

# Pretty permalinks are required for clean /wp-json/ routes
wp rewrite structure '/%postname%/' --hard

# Optional but recommended
wp plugin install wp-graphql --activate
wp plugin install advanced-custom-fields --activate

# Keep the backend out of search results (the frontend is what gets indexed)
wp option update blog_public 0

Next, stop the old theme from serving public pages. Activate a minimal theme and drop this must-use plugin into wp-content/mu-plugins/. It sends any visitor who lands on a backend URL to the same path on your frontend, while wp-admin, the REST API, WPGraphQL and the login screen keep working.

<?php
// mu-plugins/headless-redirect.php
// Make WordPress "backend-only": visitors hitting the old theme URLs are sent
// to the same path on the decoupled frontend. Admin, REST, GraphQL, cron and
// login keep working because they never reach template_redirect.

add_action( 'template_redirect', function () {

	if ( is_preview() || is_user_logged_in() ) {
		return; // editors can still open previews on the backend if needed
	}

	$frontend = 'https://www.example.com';
	$path     = isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/';

	wp_redirect( esc_url_raw( $frontend . $path ), 301 );
	exit;
} );

Step 2: Prepare your content structure

This is where good headless projects are won. Think in fields, not in pages. A “Case Study” should have a client name, an industry, a result metric and a hero image as separate fields, not a single blob of HTML. Register custom post types and meta with REST and GraphQL exposure switched on:

<?php
/**
 * Plugin Name: Headless Content Model
 * Description: Registers a "Case Study" post type and its meta for REST + WPGraphQL.
 */

add_action( 'init', function () {

	register_post_type( 'case_study', array(
		'label'               => 'Case Studies',
		'public'              => true,
		'has_archive'         => false,
		'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields' ),
		'menu_icon'           => 'dashicons-portfolio',

		// REST API exposure.
		'show_in_rest'        => true,
		'rest_base'           => 'case-studies',   // -> /wp-json/wp/v2/case-studies

		// WPGraphQL exposure (ignored if WPGraphQL is not active).
		'show_in_graphql'     => true,
		'graphql_single_name' => 'caseStudy',
		'graphql_plural_name' => 'caseStudies',
	) );

	// A typed, sanitized meta field that is readable through the REST API.
	register_post_meta( 'case_study', 'client_name', array(
		'type'              => 'string',
		'single'            => true,
		'show_in_rest'      => true,
		'sanitize_callback' => 'sanitize_text_field',
		'auth_callback'     => function () {
			return current_user_can( 'edit_posts' );
		},
	) );
} );

If you prefer a UI, Advanced Custom Fields (ACF) does the same job. Turn on Show in REST API for each field group, and install WPGraphQL for ACF if you use GraphQL. For block content, decide early whether the frontend will render the HTML from content.rendered or parse individual blocks; mixing both later is painful.

Step 3: Enable and test the WordPress REST API

The REST API is on by default, so “enabling” it really means checking that nothing (a security plugin, a firewall rule, a server config) is blocking it. Open https://cms.example.com/wp-json/ in a browser. You should see a large JSON index of every route. Then test the endpoints you will use:

# List the 5 latest published posts (public, no auth needed)
curl "https://cms.example.com/wp-json/wp/v2/posts?per_page=5"

# Return only the fields your frontend actually uses (smaller payload)
curl "https://cms.example.com/wp-json/wp/v2/posts?per_page=5&_fields=id,slug,title,excerpt,date"

# Embed featured image + author + terms in a single response
curl "https://cms.example.com/wp-json/wp/v2/posts?slug=hello-world&_embed"

# Other core endpoints you will use constantly
curl "https://cms.example.com/wp-json/wp/v2/pages"
curl "https://cms.example.com/wp-json/wp/v2/categories?per_page=100"
curl "https://cms.example.com/wp-json/wp/v2/media?parent=42"
curl "https://cms.example.com/wp-json/"          # discovery: lists every route

A typical post response looks like this. Notice that titles and excerpts arrive as rendered HTML strings, and the featured image arrives as an ID unless you add _embed:

[
  {
    "id": 128,
    "date": "2026-11-28T09:14:00",
    "slug": "wordpress-as-a-headless-cms",
    "status": "publish",
    "title": { "rendered": "WordPress as a Headless CMS" },
    "excerpt": { "rendered": "<p>Use WordPress only as a backend...</p>" },
    "featured_media": 311,
    "categories": [ 7 ],
    "_links": { "wp:featuredmedia": [ { "href": "https://cms.example.com/wp-json/wp/v2/media/311" } ] }
  }
]

The lists every parameter (per_page, page, orderby, search, _fields, _embed) and is worth bookmarking.

Step 4: Install and configure WPGraphQL (optional)

Install , activate it and open GraphQL β†’ GraphiQL IDE in the admin. Your endpoint is now https://cms.example.com/graphql. Paste this query into the IDE to fetch the five latest posts with their images, categories and author in a single request:

query LatestPosts {
  posts(first: 5, where: { status: PUBLISH }) {
    nodes {
      databaseId
      slug
      title
      date
      excerpt
      featuredImage {
        node {
          sourceUrl
          altText
          mediaDetails { width height }
        }
      }
      categories {
        nodes { name slug }
      }
      author {
        node { name }
      }
    }
  }
}

Under GraphQL β†’ Settings, consider turning on “Limit the max query amount” and disabling public introspection on production. Add the WPGraphQL Smart Cache extension if you expect heavy GraphQL traffic.

Step 5: Configure authentication and API access

Public, published content needs no authentication. Drafts, private posts, previews and anything that writes data do. The simplest secure method is Application Passwords, built into core since WordPress 5.6. Create a dedicated user with the lowest role that can do the job (often Editor or a custom role), generate an application password for it, and send it with HTTP Basic auth over HTTPS:

# 1. In WP Admin go to Users -> Profile -> Application Passwords,
#    name it "nextjs-frontend" and copy the generated password.

# 2. Read a draft post (requires authentication)
curl --user "api-user:abcd EFGH 1234 ijkl MNOP 5678" \
  "https://cms.example.com/wp-json/wp/v2/posts/128?status=draft&context=edit"

# 3. Create a post from an external app
curl --user "api-user:abcd EFGH 1234 ijkl MNOP 5678" \
  -X POST "https://cms.example.com/wp-json/wp/v2/posts" \
  -H "Content-Type: application/json" \
  -d '{"title":"Created via API","status":"draft"}'

Never put that password in client-side JavaScript. Use it only from server code (Next.js route handlers, server components, build scripts). For user logins inside the frontend, look at JWT authentication plugins or WPGraphQL’s headless login extensions. The explains the full flow, including the authorize-app screen for third-party apps.

Step 6: Connect your frontend application

Create the frontend project, add the environment variables from section 3 and build a small data layer that every page uses. Centralizing fetch logic in one file means caching, error handling and authentication are configured once:

// lib/wordpress.js  β€” shared data layer for the Next.js App Router
const WP_API = process.env.WORDPRESS_API_URL; // e.g. https://cms.example.com/wp-json

async function wpFetch(path, { revalidate = 300, tags = [] } = {}) {
  const res = await fetch(`${WP_API}${path}`, {
    next: { revalidate, tags },
  });

  if (!res.ok) {
    throw new Error(`WordPress API error ${res.status} on ${path}`);
  }
  return res.json();
}

export function getPosts(page = 1) {
  return wpFetch(`/wp/v2/posts?per_page=10&page=${page}&_embed`, { tags: ['posts'] });
}

export async function getPostBySlug(slug) {
  const posts = await wpFetch(`/wp/v2/posts?slug=${encodeURIComponent(slug)}&_embed`, {
    tags: ['posts', `post-${slug}`],
  });
  return posts[0] ?? null;
}

export function getCategories() {
  return wpFetch('/wp/v2/categories?per_page=100&hide_empty=true', { revalidate: 3600 });
}

Section 7 shows how to use this in Next.js, React and Astro pages.

Step 7: Test content delivery from WordPress

Before you call it done, run through this checklist:

  • Publish a new post and confirm it appears on the frontend within your revalidation window.
  • Update a post and confirm the change is visible (tests your webhook or cache timer).
  • Delete or unpublish a post and confirm the frontend returns a real 404, not an empty page.
  • Upload an image and confirm it loads on the frontend with correct dimensions and alt text.
  • Visit an old backend URL and confirm it 301-redirects to the frontend.
  • Check /wp-json/wp/v2/users as a logged-out visitor (it should not list your usernames; see section 10).

To make updates appear instantly instead of on a timer, wire WordPress to tell the frontend when content changes. This pair of snippets is the most important piece of production plumbing in any headless build, and most tutorials leave it out:

<?php
// mu-plugins/headless-revalidate.php
// Tell the frontend to refresh its cache whenever content is published or updated.

add_action( 'transition_post_status', function ( $new_status, $old_status, $post ) {

	if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
		return; // ignore drafts that were never public
	}
	if ( wp_is_post_revision( $post ) || wp_is_post_autosave( $post ) ) {
		return;
	}

	wp_remote_post( 'https://www.example.com/api/revalidate', array(
		'timeout'  => 5,
		'blocking' => false, // do not slow down the editor's "Update" click
		'headers'  => array(
			'Content-Type'       => 'application/json',
			'x-revalidate-token' => HEADLESS_REVALIDATE_SECRET, // defined in wp-config.php
		),
		'body'     => wp_json_encode( array(
			'type' => $post->post_type,
			'slug' => $post->post_name,
		) ),
	) );
}, 10, 3 );
// app/api/revalidate/route.js  β€” receives the webhook from WordPress
import { revalidatePath } from 'next/cache';

export async function POST(request) {
  if (request.headers.get('x-revalidate-token') !== process.env.REVALIDATE_SECRET) {
    return Response.json({ message: 'Invalid token' }, { status: 401 });
  }

  const { type, slug } = await request.json();

  if (type === 'post') {
    revalidatePath('/blog');
    revalidatePath(`/blog/${slug}`);
  } else {
    revalidatePath(`/${slug}`);
  }

  return Response.json({ revalidated: true, now: Date.now() });
}
On-demand revalidation flow for headless WordPressEditor clicks Update in WordPress, WordPress sends a webhook to the Next.js revalidate route, Next.js marks the page stale, the next visitor triggers a fresh fetch from the API and the CDN stores the new page.From “Update” click to live page in seconds✍️1. Editorclicks Updateβš™οΈ2. WordPresssends webhookπŸ”‘3. /api/revalidatechecks secret♻️4. Next.jsrebuilds the path⚑5. CDNserves new HTMLNon-blocking request (blocking => false) so editors never wait for the frontend.Shared secret in a header prevents anyone else from purging your cache.
On-demand revalidation keeps static speed without stale content.

7. How to Connect Headless WordPress with a Frontend Framework

WordPress with Next.js

Headless WordPress with Next.js is the most popular pairing for good reason: one framework covers static pages, server rendering, revalidation, image optimization and metadata. Using the data layer from step 6, a complete dynamic post route in the App Router looks like this. Note that in Next.js 15 and 16, params is a Promise and must be awaited:

// app/blog/[slug]/page.js
import { notFound } from 'next/navigation';
import { getPosts, getPostBySlug } from '@/lib/wordpress';

// Pre-render the latest posts at build time; others render on first request.
export async function generateStaticParams() {
  const posts = await getPosts();
  return posts.map((post) => ({ slug: post.slug }));
}

export async function generateMetadata({ params }) {
  const { slug } = await params;          // params is async in Next.js 15+
  const post = await getPostBySlug(slug);
  if (!post) return {};
  return {
    title: post.title.rendered,
    alternates: { canonical: `https://www.example.com/blog/${slug}` },
  };
}

export default async function PostPage({ params }) {
  const { slug } = await params;
  const post = await getPostBySlug(slug);
  if (!post) notFound();                  // real 404, not a soft 404

  const image = post._embedded?.['wp:featuredmedia']?.[0];

  return (
    <article>
      <h1 dangerouslySetInnerHTML={{ __html: post.title.rendered }} />
      {image && (
        <img
          src={image.source_url}
          alt={image.alt_text || ''}
          width={image.media_details?.width}
          height={image.media_details?.height}
        />
      )}
      <div dangerouslySetInnerHTML={{ __html: post.content.rendered }} />
    </article>
  );
}

Two details matter here. First, notFound() returns a real 404 status, which protects you from “soft 404” problems in Search Console. Second, dangerouslySetInnerHTML trusts WordPress output. That is fine when only trusted editors can publish, but keep the unfiltered_html capability restricted to administrators. The explain how Cache Components and the use cache directive can replace the next.revalidate option once you migrate.

WordPress with React

For headless WordPress with React outside a meta-framework (a Vite single-page app, a dashboard, an Electron app), you fetch in the browser. Remember that this means search engines see an empty shell until JavaScript runs, so use it for logged-in areas and widgets, not for public marketing pages. It also means the browser calls WordPress directly, so you need CORS configured (section 11).

// src/components/LatestPosts.jsx  β€” client-side React (Vite / CRA style SPA)
import { useEffect, useState } from 'react';

const API = import.meta.env.VITE_WP_API; // https://cms.example.com/wp-json

export default function LatestPosts() {
  const [posts, setPosts] = useState([]);
  const [error, setError] = useState(null);

  useEffect(() => {
    const controller = new AbortController();

    fetch(`${API}/wp/v2/posts?per_page=6&_fields=id,slug,title,excerpt`, {
      signal: controller.signal,
    })
      .then((res) => (res.ok ? res.json() : Promise.reject(res.status)))
      .then(setPosts)
      .catch((err) => err !== 'AbortError' && setError(err));

    return () => controller.abort();
  }, []);

  if (error) return <p>Could not load posts.</p>;

  return (
    <ul>
      {posts.map((post) => (
        <li key={post.id}>
          <a href={`/blog/${post.slug}`}
             dangerouslySetInnerHTML={{ __html: post.title.rendered }} />
        </li>
      ))}
    </ul>
  );
}

WordPress with Astro

Headless WordPress with Astro produces some of the fastest content sites you can build, because Astro ships zero JavaScript by default. Use getStaticPaths for a static build, or Astro 6’s stable Live Content Collections when you want content fetched at request time without rebuilding. The covers the new content layer, the Fonts API and the Node 22 requirement.

---
// src/pages/blog/[slug].astro  β€” static build (SSG) with Astro
export async function getStaticPaths() {
  const res = await fetch(`${import.meta.env.WP_API}/wp/v2/posts?per_page=100&_embed`);
  const posts = await res.json();

  return posts.map((post) => ({
    params: { slug: post.slug },
    props: { post },
  }));
}

const { post } = Astro.props;
const image = post._embedded?.['wp:featuredmedia']?.[0];
---
<html lang="en">
  <head>
    <title set:html={post.title.rendered} />
    <link rel="canonical" href={`https://www.example.com/blog/${post.slug}/`} />
  </head>
  <body>
    <article>
      <h1 set:html={post.title.rendered} />
      {image && <img src={image.source_url} alt={image.alt_text} loading="lazy" />}
      <Fragment set:html={post.content.rendered} />
    </article>
  </body>
</html>

Fetching posts, pages, categories, and media

Content REST endpoint Useful parameters
Posts /wp/v2/posts slug, categories, search, _embed, _fields
Pages /wp/v2/pages slug, parent, menu_order
Categories /wp/v2/categories per_page=100, hide_empty, parent
Tags /wp/v2/tags search, include
Media /wp/v2/media parent, media_type=image
Custom post type /wp/v2/{rest_base} Requires show_in_rest => true
Menus /wp/v2/menu-items Requires authentication by default
Search (all types) /wp/v2/search search, type, subtype

Pagination info comes back in response headers, not the body: X-WP-Total (number of items) and X-WP-TotalPages. Read them to build “next page” links. The maximum per_page value is 100.

Displaying dynamic WordPress content

Content from the block editor arrives as HTML with block class names such as wp-block-image and wp-block-columns. You have three options to style it: load the core block library stylesheet in your frontend, write your own CSS for the block classes you actually use, or parse blocks into React components (WPGraphQL Content Blocks and similar tools return blocks as structured data). Most teams start with option two and move to option three when design control becomes critical.

For images, let your framework optimize them. In Next.js, whitelist your WordPress uploads path:

// next.config.js β€” allow next/image to optimize images served by WordPress
module.exports = {
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'cms.example.com',
        pathname: '/wp-content/uploads/**',
      },
    ],
  },
};

8. WordPress REST API vs. WPGraphQL: Which Should You Use?

Understanding the WordPress REST API

The REST API organizes data into resources, each with its own URL and HTTP verbs (GET, POST, PUT, DELETE). It is in core, needs no plugin, is documented in the official handbook and works with every HTTP library, CDN and caching layer in existence because every request is a simple GET URL. Plugins like WooCommerce, Yoast SEO and Rank Math extend it with their own routes.

Understanding WPGraphQL

WPGraphQL adds a GraphQL schema on top of WordPress. Instead of many URLs you have one endpoint, and the client describes the exact shape of data it wants. The schema is typed and self-documenting, so editors in VS Code and the GraphiQL IDE autocomplete field names. It became a canonical WordPress.org plugin in 2024 when its creator joined Automattic, which gives it long-term backing.

// lib/graphql.js  β€” calling WPGraphQL from any JavaScript frontend
export async function wpGraphQL(query, variables = {}) {
  const res = await fetch(`${process.env.WORDPRESS_GRAPHQL_URL}`, { // https://cms.example.com/graphql
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ query, variables }),
    next: { revalidate: 300, tags: ['wpgraphql'] },
  });

  const json = await res.json();
  if (json.errors) {
    throw new Error(json.errors.map((e) => e.message).join('\n'));
  }
  return json.data;
}

// Usage: one request returns post + image + categories + author
const data = await wpGraphQL(`
  query PostBySlug($slug: ID!) {
    post(id: $slug, idType: SLUG) {
      title
      content
      seo: excerpt
      categories { nodes { name slug } }
    }
  }
`, { slug: 'wordpress-as-a-headless-cms' });

Performance and data-fetching differences

Rendering a typical blog post page needs the post, its featured image, its categories, the author and maybe three related posts. With REST that is often four to six requests (or one heavy _embed response full of fields you will not use). With GraphQL it is one request that returns only what you asked for.

REST API vs WPGraphQL requests to render one blog postREST needs separate requests for post, media, categories, author and related posts. WPGraphQL fetches all of it in one query.REST API: 5 round tripsWPGraphQL: 1 round tripGET /wp/v2/posts?slug=my-postGET /wp/v2/media/311GET /wp/v2/categories?include=7GET /wp/v2/users/2GET /wp/v2/posts?categories=7&per_page=3POST /graphqlpost(id: “my-post”, idType: SLUG) {title content datefeaturedImage { node { sourceUrl } }categories { nodes { name } }author { node { name } }}+ related posts in the same queryTip: REST can reduce this with _embed and _fields, at the cost of larger or less flexible responses.
GraphQL shines when a page needs nested, related data. REST shines when requests are simple and must be cached by URL.

That does not automatically make GraphQL faster. GraphQL requests are usually POSTs, which CDNs do not cache by default, and a deeply nested query can be expensive for the server. REST GET requests are trivially cacheable at every layer. In a statically generated or revalidated site, the difference mostly disappears because API calls happen at build or revalidation time, not on every visit.

API flexibility and developer experience

Criteria WordPress REST API WPGraphQL
Installation Built into core Free plugin (canonical)
Endpoints Many (one per resource) One (/graphql)
Over-fetching Common; reduce with _fields None; you request exact fields
Nested data Multiple calls or _embed Single query
Typed schema JSON Schema per route Strongly typed, introspectable
HTTP caching Easy (GET URLs) Needs Smart Cache / persisted queries
Writing data Full CRUD on core routes Mutations available
Plugin support WooCommerce, Yoast, Rank Math, most plugins Extensions for ACF, Yoast, WooCommerce and more
Learning curve Low Medium
Best for Simple sites, integrations, mobile apps, webhooks Component-driven frontends with complex pages

Choosing the right API for your project

Pick the WordPress REST API if your pages are simple, you want zero extra plugins, you integrate with tools that already speak REST, or you rely heavily on CDN caching. Pick WPGraphQL if your pages pull data from many relationships, your team already uses GraphQL, or you want type generation for TypeScript. There is no rule against using both, and many production sites do.

9. How to Optimize Headless WordPress for SEO

A common myth says headless sites rank badly. The truth is narrower: headless WordPress SEO only fails when the frontend forgets to output what an SEO plugin used to print automatically. Search engines index the frontend, so the frontend must deliver complete, server-rendered HTML with every tag in place.

Configure SEO titles and meta descriptions

Keep editing SEO fields in Yoast SEO or Rank Math (if you are still choosing, our comparison of Rank Math vs Yoast covers the differences). Both expose their output to headless frontends. Yoast adds a yoast_head_json object to REST responses. Rank Math offers a dedicated endpoint after you enable “Headless CMS Support”.

// Yoast SEO adds a "yoast_head_json" object to every REST post response.
const post = await getPostBySlug(slug);
const seo  = post.yoast_head_json;

export const metadata = {
  title: seo.title,
  description: seo.description,
  alternates: { canonical: seo.canonical.replace('https://cms.example.com', 'https://www.example.com') },
  openGraph: { title: seo.og_title, description: seo.og_description, images: seo.og_image },
  robots: seo.robots,
};

// Rank Math: enable "Headless CMS Support" (General Settings -> Others), then:
// GET https://cms.example.com/wp-json/rankmath/v1/getHead?url=https://cms.example.com/my-post/
// The response contains the full <head> HTML string for that URL.

Implement canonical URLs

SEO plugins generate canonicals using the WordPress site URL, which in a headless setup is the backend domain. Always rewrite cms.example.com to your public domain before printing the tag (as in the snippet above), or set the canonical yourself from the frontend route. A canonical that points to the CMS subdomain is one of the most damaging headless mistakes because it tells Google the backend is the real page.

Generate XML sitemaps

The SEO plugin’s sitemap lists backend URLs, so generate the sitemap in the frontend from API data. In Next.js it is one file:

// app/sitemap.js  β€” Next.js generates /sitemap.xml from WordPress content
import { getPosts } from '@/lib/wordpress';

export default async function sitemap() {
  const posts = await getPosts();

  const postUrls = posts.map((post) => ({
    url: `https://www.example.com/blog/${post.slug}`,
    lastModified: post.modified_gmt ? new Date(post.modified_gmt + 'Z') : new Date(),
    changeFrequency: 'weekly',
    priority: 0.7,
  }));

  return [
    { url: 'https://www.example.com', lastModified: new Date(), priority: 1 },
    { url: 'https://www.example.com/blog', lastModified: new Date(), priority: 0.8 },
    ...postUrls,
  ];
}

For sites with more than a few hundred posts, loop through all pages of the API using the X-WP-TotalPages header, or split into multiple sitemaps with generateSitemaps.

Add structured data and schema markup

Build JSON-LD from the same API data you render, so the schema always matches the visible content. Article, BreadcrumbList, Organization, Product and FAQPage are the most useful types for WordPress content. Yoast’s yoast_head_json.schema object can also be printed directly if you prefer to keep schema in WordPress.

// Inside a Next.js page component: Article structured data built from WordPress data
const articleSchema = {
  '@context': 'https://schema.org',
  '@type': 'Article',
  headline: post.title.rendered,
  datePublished: post.date_gmt + 'Z',
  dateModified: post.modified_gmt + 'Z',
  image: image?.source_url,
  author: { '@type': 'Person', name: post._embedded?.author?.[0]?.name },
  mainEntityOfPage: `https://www.example.com/blog/${post.slug}`,
};

<script
  type="application/ld+json"
  dangerouslySetInnerHTML={{ __html: JSON.stringify(articleSchema) }}
/>

Optimize images and Core Web Vitals

Use your framework’s image component (Next.js next/image, Astro <Image />) so images get modern formats, responsive sizes and explicit dimensions. Always pass width and height from media_details to prevent layout shift. Pre-render or revalidate pages instead of fetching in the browser so the largest content appears in the first HTML response. Keep client-side JavaScript small: a headless site that hydrates a giant bundle loses the performance advantage that justified going headless.

Manage redirects and URL structures

WordPress redirect plugins only act on backend URLs. Move redirect rules to the frontend (redirects() in next.config.js, Astro’s redirects config, or your host’s redirect file). If you are migrating an existing site, export every old URL first and keep the same slugs on the frontend so link equity carries over. Plan trailing-slash behaviour once and keep it consistent everywhere.

Handle robots.txt and indexing

Two domains, two policies. The frontend should be fully indexable with its own robots.txt and sitemap. The backend should not appear in search at all, but media files on it are still used by the frontend, so prefer an X-Robots-Tag: noindex header on HTML responses over blocking the whole domain in robots.txt.

# robots.txt on the FRONTEND (www.example.com) β€” this is the site Google should index
User-agent: *
Allow: /
Sitemap: https://www.example.com/sitemap.xml

# On the BACKEND (cms.example.com), keep the admin out of the index instead with
# a response header, so crawlers can still fetch media files that the frontend uses:
#   X-Robots-Tag: noindex, nofollow   (for HTML responses on cms.example.com)

10. Headless WordPress Security Best Practices

Going headless removes a lot of attack surface (no public theme, no exposed plugin output, no database on the frontend server), which is why roughly half of headless adopters in vendor surveys cite stronger security as a benefit. It also adds new surfaces: API endpoints, CORS, tokens and webhooks. Start with a general WordPress security checklist, then add these headless WordPress security measures.

Secure WordPress admin access

  • Put the backend on a subdomain that is not linked from the public site.
  • Restrict /wp-admin and /wp-login.php by IP, VPN or an authentication proxy (Cloudflare Access, basic auth in front of the login page) when your editors work from known locations.
  • Enforce two-factor authentication for every account that can publish.
  • Rate-limit login attempts and disable XML-RPC, which a headless site never needs.

Protect REST API endpoints

Leave public read endpoints for published content open (that is the point), but close what you do not need. The users endpoint is the classic leak: by default it lists usernames to anyone, which helps brute-force attacks.

<?php
// Hide the public /wp/v2/users endpoint from anonymous visitors
// (stops username enumeration while keeping it for logged-in API clients).
add_filter( 'rest_endpoints', function ( $endpoints ) {
	if ( is_user_logged_in() ) {
		return $endpoints;
	}
	unset( $endpoints['/wp/v2/users'] );
	unset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] );
	return $endpoints;
} );

// Optional: block XML-RPC entirely β€” a headless site never needs it.
add_filter( 'xmlrpc_enabled', '__return_false' );

Also make sure custom endpoints you register always have a real permission_callback. Since WordPress 5.5, routes without one trigger a notice; routes that return __return_true for write actions are a serious hole. Validating and sanitizing every input in your custom routes is not optional.

Configure authentication securely

  • Use Application Passwords or short-lived tokens, never your admin password.
  • Create a dedicated API user with the minimum role required, one per integration, so you can revoke access individually.
  • Keep credentials in server-side environment variables. Anything prefixed NEXT_PUBLIC_ or VITE_ is shipped to every visitor’s browser.
  • Protect preview and revalidation routes with long random secrets and rotate them.

Use HTTPS and secure API communication

Basic authentication sends credentials with every request, so HTTPS on the backend is mandatory. Enable HSTS, keep TLS certificates on auto-renewal and, if your frontend and backend run on infrastructure you control, consider allowing write requests only from your frontend’s IP range at the firewall.

Manage user roles and permissions

Audit who can publish. In a headless site, editors’ HTML flows straight into dangerouslySetInnerHTML or Astro’s set:html, so the unfiltered_html capability should stay with administrators only. Remove old accounts and review Application Passwords on each user profile regularly.

Keep WordPress core, themes, and plugins updated

The backend is still WordPress, and outdated plugins are still the number one way WordPress sites get compromised. Enable automatic minor updates, update plugins weekly, remove anything unused, and remember the frontend has its own dependency tree: run npm audit and keep Next.js or Astro on a supported version. WordPress 7.0, released on May 20, 2026, is the current major version.

11. Common Headless WordPress Problems and How to Fix Them

Symptom Likely cause Fix
/wp-json/ returns 404 Plain permalinks or missing rewrite rules Set any non-plain permalink and save; check .htaccess or Nginx try_files
401 with a correct Application Password Server strips the Authorization header Pass the header through in Apache or Nginx (see below)
rest_forbidden / 403 Security plugin or WAF blocking the API, or user lacks capability Whitelist the routes; check the API user’s role
CORS error in the browser console Browser calling WordPress from another origin Allow your frontend origin, or fetch server-side instead
Images broken on frontend Relative URLs, hotlink protection, or image domain not allowed Allow the uploads path in your framework; disable hotlink rules for your domain
New posts 404 on the frontend Static build without fallback or revalidation Allow dynamic params and add on-demand revalidation
Changes take hours to appear Long cache time, no webhook Add the publish webhook from step 7
Canonical points to the CMS domain SEO plugin uses the WordPress site URL Rewrite the domain in the frontend before output

REST API connection errors

Start with curl -I https://cms.example.com/wp-json/. A 404 means routing (permalinks, rewrite rules, a missing try_files line in Nginx). A 403 means something is blocking: a security plugin that “disables the REST API”, a host firewall or Cloudflare bot rules challenging your build server. A timeout during builds usually means you are firing hundreds of parallel requests at a small server; add concurrency limits or cache with Redis on the backend.

Authentication and permission issues

If Application Passwords return 401 even though they are correct, your server is almost certainly dropping the Authorization header before PHP sees it. This is especially common on shared Apache hosting and some FastCGI setups:

# Apache: some hosts strip the Authorization header, which breaks
# Application Passwords with a 401. Add this to .htaccess above the WordPress block:
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Nginx equivalent inside the PHP location block:
#   fastcgi_param HTTP_AUTHORIZATION $http_authorization;

If you get 403 instead, the credentials work but the user’s role cannot perform that action. Check capabilities, and remember that some endpoints (menus, settings) require authentication even for reads.

Missing images and media URLs

Use the absolute source_url from the media object, not URLs parsed out of content HTML. If images load in WordPress but not on the frontend, look for hotlink protection on the host or CDN, a missing remotePatterns entry in Next.js, or mixed content (HTTP image URLs on an HTTPS frontend). After a domain change, search-and-replace old URLs in the database with WP-CLI.

CORS errors

Browsers block JavaScript from reading responses from another origin unless the server explicitly allows it. The cleanest fix is to avoid the problem: fetch from server components, API routes or build scripts, where CORS does not apply. When the browser genuinely must call WordPress (a client-side React widget), allow only your own origins. The explains preflight requests if you get stuck.

<?php
// Allow only your own frontend origins to call the REST API from the browser.
add_action( 'rest_api_init', function () {

	remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );

	add_filter( 'rest_pre_serve_request', function ( $value ) {
		$allowed = array(
			'https://www.example.com',
			'http://localhost:3000', // local development β€” remove in production
		);
		$origin  = get_http_origin();

		if ( $origin && in_array( $origin, $allowed, true ) ) {
			header( 'Access-Control-Allow-Origin: ' . esc_url_raw( $origin ) );
			header( 'Access-Control-Allow-Methods: GET, POST, OPTIONS' );
			header( 'Access-Control-Allow-Headers: Authorization, Content-Type' );
			header( 'Access-Control-Allow-Credentials: true' );
			header( 'Vary: Origin' );
		}
		return $value;
	} );
}, 15 );

Frontend routing and 404 errors

Make sure your dynamic route matches WordPress’s permalink structure, including nested pages (/services/web-design/ needs a catch-all route like [...slug]). Allow on-demand rendering for slugs that were not generated at build time, and call notFound() (or return a 404 in Astro) when the API returns an empty array, so search engines see a real 404 status.

SEO metadata and indexing problems

View the page source (not the DevTools element tree) on the frontend and confirm that title, meta description, canonical, Open Graph tags and JSON-LD are in the initial HTML. Run the URL Inspection tool in Search Console to see what Google renders. If the backend domain shows up in search results, add noindex headers there and make sure the redirect from step 1 is active.

12. When Should You Use (or Avoid) Headless WordPress?

Should you use headless WordPress? Decision flowchartThree questions: Do you have JavaScript developers to maintain a frontend? Do you need multiple channels, custom UX or high traffic performance? Do editors depend on page builders and frontend plugins? The answers lead to headless, hybrid or traditional WordPress.Should you go headless? A 30-second testDo you have JavaScript developersto own a second codebase?NoStay traditionalfast theme + cachingYesNeed multiple channels, custom UXor heavy / spiky traffic?Not reallyConsider hybridtheme + JS islandsYesDo editors depend on Elementor/Divior many frontend plugins?YesPlan a rebuild firstor stay hybridNoGo headless βœ“Next.js or Astro + WP
Team skills come first. Without someone to own the frontend, headless WordPress becomes an expensive liability.

Best use cases for headless WordPress

  • Publishers and media sites with large archives and unpredictable traffic spikes.
  • Brands with apps that need the same content on the web, iOS and Android.
  • Marketing sites built by product teams that already work in React and want a familiar editor for the marketing department.
  • Multisite and multi-brand setups where one CMS feeds several differently designed frontends.
  • Documentation and knowledge bases where Astro’s static output and search integrations shine.
  • Agencies that standardize on one frontend stack across many clients while keeping WordPress for editing.

When traditional WordPress is a better choice

  • Small business, portfolio and brochure sites where a fast theme is more than enough.
  • Sites built and edited visually with Elementor, Divi, Beaver Builder or full site editing.
  • Projects with a fixed, small budget or no developer on retainer.
  • Sites that depend on many frontend plugins: booking calendars, membership content gating, LMS course players, complex forms.
  • Teams that want instant WYSIWYG preview without configuration.

Headless WordPress for blogs, eCommerce, and business websites

Blogs: headless is easy and rewarding for blogs because the data model is simple (posts, categories, authors). Astro or a statically generated Next.js site is a great fit.

eCommerce: headless WooCommerce is entirely possible, but much more work. If you need a refresher on how WooCommerce works under the hood, start there. Product catalogs are easy through the , which was built for custom frontends and handles carts without exposing admin keys. Checkout, payment gateways, taxes, coupons and customer accounts all need careful frontend work, and many payment plugins only support the classic or block checkout. A common compromise is a headless catalog with a hand-off to the standard WooCommerce checkout.

# WooCommerce Store API β€” public, cart-aware endpoints built for custom frontends
curl "https://cms.example.com/wp-json/wc/store/v1/products?per_page=12"
curl "https://cms.example.com/wp-json/wc/store/v1/products/categories"

# Cart actions use a Nonce or Cart-Token header returned by the first cart request
curl -i "https://cms.example.com/wp-json/wc/store/v1/cart"

Business websites: worth it when the site is a core sales channel with a dedicated web team; usually not worth it for a ten-page company site.

Development costs and maintenance considerations

Plan for these recurring costs, not just the initial build:

  • Hosting: two environments (WordPress hosting plus frontend hosting, often with usage-based bandwidth and function pricing).
  • Development: people comfortable with both PHP/WordPress and JavaScript frameworks. A solid grasp of APIs, authentication and caching (the core of any backend developer skills list) is essential.
  • Maintenance: WordPress and plugin updates, plus framework major upgrades (Next.js and Astro both ship breaking changes yearly).
  • Features you used to get for free: previews, forms, search, comments, redirects, sitemaps and analytics consent all need building or a third-party service.

Vendor-commissioned studies report strong returns from headless platforms, and 73% of organizations in a WP Engine survey say they already use headless in some form. Treat those numbers as directional, since most of the research is funded by CMS vendors, and run your own cost estimate against your team and traffic.

13. Frequently Asked Questions About Headless WordPress

Is WordPress good as a headless CMS?

Yes. WordPress gives you a mature editor, roles, revisions, media management, multilingual plugins and a huge talent pool, plus a built-in REST API and a canonical GraphQL plugin. Its weaknesses are that it was not designed API-first, so you must deliberately structure content and rebuild frontend-only plugin features. For teams that already know WordPress, it is often a better headless CMS than a new SaaS platform their editors would have to learn.

Can I use WordPress without a frontend?

Yes. A WordPress install still needs an active theme technically, but you can use a minimal one and redirect all public requests to your separate frontend, as shown in step 1. Editors use /wp-admin, applications use /wp-json/ or /graphql, and visitors never see the theme.

Is headless WordPress faster than traditional WordPress?

It can be much faster, because pre-rendered pages are served from a CDN without touching PHP or MySQL. It is not automatically faster: a JavaScript-heavy frontend or a site that calls the API on every request can be slower than a well-cached classic theme. Speed comes from the rendering strategy, not from the word “headless”.

Does headless WordPress improve SEO?

Not by itself. It gives you the tools for excellent Core Web Vitals and full control over markup, which helps. But you must recreate titles, meta descriptions, canonicals, sitemaps, schema and redirects in the frontend. Done properly, a headless site ranks as well as or better than a traditional one. Done carelessly, it can lose rankings overnight.

Can I use Elementor with headless WordPress?

Not in any practical way. Elementor, Divi and similar page builders generate HTML, CSS and JavaScript tied to the WordPress theme layer. A headless frontend receives that markup without the styles and scripts that make it work. If visual page building is essential, use the block editor with structured blocks that your frontend renders as components, or stay with traditional WordPress.

Is WordPress REST API free?

Yes. The REST API is part of WordPress core and open source under the GPL, with no usage fees or rate limits imposed by WordPress itself. Your only costs are the hosting resources needed to answer API requests. WPGraphQL is also free.

Can I use WooCommerce with headless WordPress?

Yes. Use the WooCommerce Store API for product listings, carts and checkout from a custom frontend, and the authenticated WooCommerce REST API for admin-level tasks like order management. Expect extra work for payments, taxes and account pages, and check that your payment gateway supports a headless or Store API checkout before you commit.

Do I need to know React to use headless WordPress?

Someone on the project does, or Vue, Svelte or another JavaScript framework. Astro lowers the bar because its templates are close to HTML, but you still need JavaScript knowledge for data fetching, builds and deployment.

How do content previews work in a headless setup?

The preview button in WordPress is pointed at a protected route on the frontend (in Next.js, a route that enables Draft Mode). That route uses an authenticated request, usually with an Application Password from server code, to fetch the draft or latest revision and renders it with the same components as live pages. Faust.js and similar toolkits provide this out of the box.

14. Conclusion

Using WordPress as a headless CMS lets you keep the editing experience millions of people already know while building the frontend with whatever technology serves your users best. The recipe is straightforward: install WordPress on its own subdomain, model content as structured fields, expose it through the WordPress REST API or WPGraphQL, secure the API, and render it with Next.js, React or Astro, with a publish webhook to keep everything fresh.

The hard parts are not the API calls. They are the things a theme used to give you for free: SEO tags, previews, redirects, forms and plugin output. Plan for those from day one and headless WordPress becomes a fast, secure and future-proof platform. Skip them, and you inherit two systems that both need maintaining.

If your team has JavaScript skills and your project needs speed, scale or multiple channels, start small: put one section of your site (a blog or a docs area) on a headless frontend, measure the results, and expand from there.

Further reading and sources

Inspire us with your love!

Saiful Islam

By Saiful Islam

Saiful Islam, the founder of aThemeArt, is a successful freelancer, a father of two boys, and an enthusiast in coding, YouTube, and gaming. Connect with me on Twitter, Facebook, and Instagram to stay updated with my latest endeavors.

You can check also

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*