Talk to an engineer

WordPress to Next.js: a headless migration guide

Keep the WordPress admin your editors know and move the public site to Next.js: architecture, REST API or WPGraphQL, previews, caching, plugins, SEO and the order of work.

SeaPHP engineering · October 29, 2026 · Updated December 1, 2026

Large WordPress sites often reach the same impasse. Editors like the admin. The front end, built from a theme and a stack of plugins over many years, is slow, hard to change and a steady source of security updates. Moving off WordPress entirely means retraining every editor and migrating years of content. Doing nothing means living with the front end.

Headless WordPress with Next.js is the middle path: keep WordPress as the content system, and move the public site to Next.js. This guide covers how the two fit together, the decisions you have to make, and the order to do the work in so the site stays live and keeps its rankings throughout.

When a Next.js front end is worth it

Go headless when at least two of these are true:

  • Performance is a business problem, and caching plugins and image optimization have not fixed it.
  • The design team is blocked by the theme, and front-end changes take developer time that should go elsewhere.
  • Security updates are constant, mostly from front-end plugins.
  • Content feeds more than one front end: a website, an app, a partner portal.
  • The front-end team works in React and the theme is maintained reluctantly.

Do not go headless when the site's value is in plugins that only work through a WordPress theme, such as some commerce, membership and learning plugins, unless you are ready to rebuild those features.

How headless WordPress fits together

  • WordPress stays the content system. Editors write, schedule and approve in the admin they already know. Custom post types, custom fields and taxonomies keep working.
  • Next.js renders the public site. It reads content through the WordPress REST API or a GraphQL layer such as WPGraphQL, and serves pages that are static, server-rendered or a mix of both.
  • The two are deployed separately. WordPress can move behind a firewall or onto a private network. The public only ever reaches Next.js.

The security picture improves immediately. The theme and most front-end plugins are gone from the request path, and the WordPress installation is no longer on the public internet. The PHP that remains is smaller and easier to patch, and can be covered by long-term support if the PHP version is old.

REST API or WPGraphQL

Both are production ready. The choice is about how your content is shaped.

WordPress REST API WPGraphQL
Installed Built into core A plugin
Requests per page Often several (post, author, terms, media) Usually one
Payload Fixed shape per endpoint, trimmed with _fields Exactly the fields you ask for
Custom fields Need registering with register_rest_field or show_in_rest Exposed through the schema, with extensions for popular field plugins
Typing in TypeScript Write types by hand Generate types from the schema
Caching Plain GET requests, easy to cache at a CDN Use GET requests or persisted queries to cache well

Sites with simple posts and pages are well served by the REST API. Sites with deep custom field structures, related content and many content types tend to prefer WPGraphQL.

A minimal read from the REST API in a Next.js Server Component:

// app/[slug]/page.tsx
import { notFound } from 'next/navigation';

export default async function Page({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params;
  const res = await fetch(
    `${process.env.WP_URL}/wp-json/wp/v2/posts?slug=${encodeURIComponent(slug)}&_embed=1`,
    { next: { revalidate: 3600 } },
  );
  const [post] = await res.json();
  if (!post) notFound();
  return <article dangerouslySetInnerHTML={{ __html: post.content.rendered }} />;
}

Rendering WordPress HTML directly is fine for a first release. Later, parse blocks into React components so embeds, images and callouts get the same treatment as the rest of the site.

Previews for editors

Previews are the feature editors notice first if they break. WordPress's Preview button has to open a Next.js page that shows the unpublished draft.

  1. Point WordPress's preview link at a Next.js route, for example /api/preview?id=123&secret=..., using the preview_post_link filter.
  2. In that route, check the secret, enable Next.js Draft Mode, and redirect to the post's URL.
  3. Pages check Draft Mode and, when it is on, fetch the latest revision with an authenticated request (an application password or a JWT) instead of the published version, skipping the cache.

Test previews for every post type, including scheduled posts and posts that have never been published.

Caching and publishing

Static pages are what make headless WordPress fast. The question is how a published change reaches them.

  • Time-based revalidation: pages refresh every few minutes or hours. Simple, but editors wait.
  • On-demand revalidation: a small WordPress plugin or hook calls a Next.js route when a post is saved, and that route calls revalidatePath for the post, its archives and the home page. Published changes appear in seconds.

Use on-demand revalidation for posts and pages, with a long time-based fallback in case a webhook is missed.

Plugins: keep, replace or drop

Audit every active plugin before estimating. Each falls into one of three groups:

  • Keep: plugins that work on content and the admin. Custom fields, editorial workflow, user roles, redirects managers, multilingual content. Check each exposes its data to the API you chose.
  • Replace on the Next.js side: plugins that change what visitors see. Page builders, sliders, galleries, forms, cookie banners, search, related posts. Forms usually become Server Actions posting to your form service; search becomes a search service or a database query.
  • Drop: caching, minification, image optimization and security plugins that protected the public front end. Next.js and the CDN now do that work.

Page builders deserve their own line in the plan. Content stored as builder shortcodes or proprietary markup does not render outside the theme, and may need converting to blocks before the front end can move.

SEO: carry everything over

  • Keep every URL, including archives, tags, attachment pages you want indexed, and the trailing slash convention.
  • Read titles, descriptions, canonical URLs and schema from your SEO plugin. Yoast SEO and Rank Math both expose their data to the REST API, and both have WPGraphQL extensions.
  • Move the sitemap and robots.txt to Next.js, generated from WordPress content.
  • Rebuild redirects from the redirects plugin as Next.js redirects, or have Next.js look them up.
  • Compare the rendered HTML of old and new pages before switching each template.

The order of work

Treat it as a strangler migration. Put Next.js in front, pass unmatched routes to the existing WordPress front end, and move templates one at a time:

  1. Single posts and pages, which are usually the bulk of traffic
  2. Archives, categories and tags
  3. The home page and landing pages
  4. Search
  5. Anything interactive: forms, comments, gated content

Each step is live, measured and reversible. When the last template has moved, lock the WordPress front end so it only serves the admin and the API.

What we learned from WordPress care at scale

Running care for thousands of WordPress sites teaches you where the risk is. It is almost never core. It is the long tail of plugins and theme code that runs on every request, each with its own update cycle and its own idea of what PHP version it supports. A headless front end removes most of that tail from the public request path. That alone can turn a site that needs weekly emergency updates into one that needs routine maintenance.

The WordPress that remains still runs on PHP, and still needs a supported PHP version. Upgrade it as part of the project, or cover it while you plan the upgrade.

When not to go headless

Small sites with a handful of editors and no performance problem do not need it. Neither do sites whose value is in plugins that only work with a WordPress theme. For those, a well-maintained WordPress site on a current PHP version is the better answer.

For the general pattern behind this guide, see the PHP to Next.js migration guide. For help running one, see WordPress to Next.js migration.

Questions we get asked

Can I keep using the WordPress admin with a Next.js front end?

Yes. That is the point of headless WordPress. Editors write, schedule and approve content in wp-admin as before. Next.js reads the content through the REST API or WPGraphQL and renders the public site.

REST API or WPGraphQL?

The REST API is built into core and needs nothing extra. WPGraphQL fetches exactly the fields a page needs in one request and has a typed schema, which suits sites with many custom fields and nested content. Both work; pick one and use it everywhere.

What happens to my plugins?

Plugins that work on content, such as custom fields, SEO and editorial workflow, keep working. Plugins that change what visitors see, such as page builders, sliders, forms and some membership plugins, need a replacement on the Next.js side.

Does headless WordPress improve security?

Usually, yes. The theme and front-end plugins leave the public request path, and WordPress can sit on a private network that only Next.js and your editors can reach.

Is headless WordPress worth it for a small site?

Rarely. A small site with a few editors and no performance problem is better served by a well-maintained WordPress install on a supported PHP version.

Find out what your PHP estate needs

Tell us which versions you run and where. An engineer replies within one business day.