WordPress

Headless WordPress with Next.js: How It Works, Pros & Cons

Headless WordPress keeps the dashboard your team knows and hands the front end to Next.js. How the architecture works, the eight steps to build one, and the honest trade-offs.

Why go headless at all?

Headless WordPress means keeping WordPress for what it does best, content editing, and handing the visitor-facing site to a modern JavaScript framework like Next.js. Your marketing team still logs into the familiar dashboard. Your visitors get a fast, app-like site that never touches a PHP theme.

It's not the right move for every site. A five-page brochure site for a local business is almost always better served by a well-built traditional WordPress theme. But for content-heavy brands, multi-channel publishing, or teams that want React-level control over the front end, headless can be a big upgrade.

This post covers how the architecture works, how a build actually comes together, and the honest pros and cons so you can decide whether it fits your project.

How the architecture works

A headless build splits one website into three layers that talk over an API.

  EDITOR
    │
    ▼
┌─────────────────┐     ┌──────────────────┐     ┌─────────────────┐
│   WordPress     │────▶│   WPGraphQL      │────▶│    Next.js      │
│ cms.brand.com   │JSON │   or REST API    │     │  React + static │
│ posts, pages,   │     │                  │     │  HTML at build  │
│ menus, fields   │     └──────────────────┘     └────────┬────────┘
└────────┬────────┘                                       │
         │                                                ▼
         │           Publish webhook              ┌─────────────────┐
         └───────────────────────────────────────▶│    CDN edge     │
                 revalidate changed pages         │    VISITOR      │
                                                  └─────────────────┘

How it's done: building a headless WordPress + Next.js site

A production build comes down to eight steps. The WordPress side is mostly configuration; the real work lives in the Next.js app.

  1. Expose your content through an API. WordPress ships with a REST API, but most headless builds use WPGraphQL, a free plugin that is becoming an official canonical WordPress plugin with Automattic's backing. GraphQL lets the front end ask for exactly the fields a page needs in one request.

    • Add WPGraphQL for ACF if you use Advanced Custom Fields.
    • Add the GraphQL extension for your SEO plugin (Yoast or Rank Math) so titles, descriptions and canonicals come through.
  2. Model the content. Register custom post types and ACF field groups with show_in_graphql enabled. Structured fields (hero headline, CTA, testimonials) are far easier to render in React than one big blob of editor HTML.

  3. Lock down the old front end. Put WordPress on a subdomain like cms.yourbrand.com, block it from search engines, and redirect any theme URLs to the new site so you don't create duplicate content.

  4. Scaffold the Next.js app. Use the App Router and keep your GraphQL endpoint in an environment variable. A small fetch helper is all you need to start:

    // lib/wp.ts
    export async function wp<T>(query: string, variables = {}, tags = ['wp']) {
      const res = await fetch(process.env.WP_GRAPHQL_URL!, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ query, variables }),
        next: { tags }, // lets us invalidate this data on publish
      });
      const { data, errors } = await res.json();
      if (errors) throw new Error(errors[0].message);
      return data as T;
    }
    
  5. Map WordPress URLs to routes. A catch-all route (app/[...slug]/page.tsx) looks up any URI with WPGraphQL's nodeByUri query and picks a template by content type, much like the WordPress template hierarchy. generateStaticParams pre-builds your most important pages.

  6. Render the content. The quick route is injecting the post's HTML (sanitized). The better route parses Gutenberg blocks into data and maps each block to a React component, so editors keep the block editor and developers keep full control of markup.

  7. Rebuild pages when editors publish. Pages are cached as static HTML. A save_post hook in WordPress pings a secured Next.js route handler, which marks just the affected data stale:

    // app/api/revalidate/route.ts
    import { revalidateTag } from 'next/cache';
    
    export async function POST(req: Request) {
      if (req.headers.get('x-secret') !== process.env.REVALIDATE_SECRET) {
        return new Response('Unauthorized', { status: 401 });
      }
      const { tag = 'wp' } = await req.json();
      revalidateTag(tag, 'max');
      return Response.json({ revalidated: true });
    }
    

    The 'max' profile marks the tagged data stale rather than deleting it: the next visitor is served the cached page immediately while the fresh copy is fetched behind them. If an editor needs the change to appear on the very next request instead, reach for updateTag in a Server Action.

  8. Wire up previews and SEO. Use Next.js Draft Mode with an authenticated request so the WordPress Preview button shows unpublished drafts. Pull SEO fields into generateMetadata, and rebuild sitemaps and redirects on the Next.js side.

If you'd rather not assemble all of this by hand, Faust.js from WP Engine is a Next.js-based framework that packages previews, authentication and template routing for headless WordPress. Many teams still prefer plain Next.js + WPGraphQL for fewer opinions and fewer dependencies.

The pros

The cons and hidden costs

Should you go headless?

Go headless when performance, security or multi-channel publishing are worth a bigger build. Stay traditional when speed to launch, budget and marketer self-service matter more.

Your situation Better fit
Content-heavy brand, publishes daily, traffic spikes Headless
Same content feeds a website plus an app or other channels Headless
In-house dev team comfortable with React Headless
Strict security or compliance requirements Headless
Small business site under ~20 pages Traditional
Marketing team builds landing pages in Elementor or Breakdance Traditional
WooCommerce store with lots of payment and shipping plugins Traditional
Tight budget or launch deadline in weeks Traditional

There's also a middle path: keep WordPress fully in charge of the site and move only one high-value section, such as a product configurator or resource library, to a React app.

Headless WordPress isn't an upgrade by default. It's a trade: more performance and control in exchange for more engineering. Get the API, previews, revalidation and SEO plumbing right on day one, and editors get a CMS they know while visitors get a site that feels instant.

How RAWR builds headless WordPress sites

We use a modern, AI-accelerated stack that keeps WordPress for content and puts every other layer on purpose-built tools. The result is a faster build without cutting corners on code quality.

  1. WordPress for content. Your team writes and publishes in the dashboard they already know. We set up WPGraphQL, custom fields and SEO data so every piece of content is structured and ready for the front end.
  2. Claude for design. If you don't have a design already, we use Claude to create the full website design: page layouts, components and a design system. You review and refine it before any code is written.
  3. Claude Code for the build. We build the Next.js front end with Claude Code, pairing AI speed with 18+ years of hands-on web development. Every component, query and SEO detail is reviewed by a human before it ships.
  4. GitHub for the codebase. All code lives in a GitHub repository with full version history, so changes are tracked, reviewable and reversible. You own the repo.
  5. Vercel (or similar) for deployment. Every push to GitHub deploys automatically to a global CDN, with preview links for each change before it goes live. Netlify and other hosts work too if you have a preference.

This workflow lets us deliver headless builds in a fraction of the traditional timeline, while you keep full ownership of your content, design and code.

Thinking about going headless? RAWR builds both traditional and headless WordPress sites, so we'll tell you honestly which one fits. Get in touch for a quick architecture review.

BW
Written by

Bobby Wilson

Founder, RAWR — a Plano, TX digital agency for AEO/SEO, AI app development, and WordPress. We help small businesses get found, get faster, and get automated.

Work with RAWR
Blockfall — match four, get paid in blocks. Play free.

Want to know if AI is recommending you?

No pitch deck. No retainer trap. Just a free audit that shows you exactly where the wins are.

Book a Free Audit