WordPress and Next.js is a combination that keeps appearing in developer conversations, agency pitches and conference talks. The idea is simple: keep WordPress as the place where editors write and manage content, but let Next.js, a React framework, build the website that visitors actually see. Is this a genuinely new way to use WordPress, or just a fashionable way to make a simple website more complicated?
In this guide, we explain how the setup works, what you gain, what you give up and how to decide whether it is right for your project.
What Does WordPress and Next.js Actually Mean?
In a traditional WordPress site, one system does everything. WordPress stores the content, runs the theme and plugins, builds each page and sends the finished HTML to the visitor. In a headless (or decoupled) setup, those jobs are split in two:
- WordPress is the back end. Editors still log in to the familiar dashboard to write posts, manage media and edit custom fields.
- Next.js is the front end. It requests the content through an API, turns it into pages with React components and serves them to visitors.
WordPress can expose its content in two main ways. The REST API is built into WordPress core. WPGraphQL is a free, open-source plugin that adds a GraphQL API, letting a front end ask for exactly the fields it needs in a single request. According to the plugin directory, WPGraphQL requires WordPress 6.0 or higher and PHP 7.4 or higher, and it is commonly used with JavaScript frameworks such as Next.js, Astro and SvelteKit.
Is It Really a New Way to Use WordPress?
Not exactly. WordPress has offered a REST API in core since version 4.7, released in late 2016, so using it as a content back end has been possible for years. What has changed is how attractive the front-end side has become. Next.js can pre-render pages, cache them and refresh them when content changes, which makes a decoupled site far more practical than it once was.
The honest answer is that WordPress and Next.js is a new option, not a new default. Most WordPress sites will continue to run perfectly well on a traditional theme. Headless is a tool for specific situations, and it comes with real costs. If you want the broader picture first, our article on headless WordPress for enterprise speed and security explains the concept from a business point of view.
How the Architecture Works
Although the details vary by project, a typical WordPress and Next.js setup follows the same flow:
- An editor publishes or updates a post in the WordPress dashboard.
- Next.js requests the content from WordPress through the REST API or WPGraphQL and builds the page.
- The rendered page is cached, so most visitors receive a pre-built page instead of waiting for a database query.
- When content changes, WordPress notifies Next.js through a webhook, and Next.js refreshes only the affected pages.
- For unpublished drafts, Next.js can use Draft Mode with authenticated requests so editors can preview their work.
Vercel, the company behind Next.js, publishes an example template that shows this pattern. It uses the App Router, fetches content through WPGraphQL, tags every request so pages refresh through a revalidation route when WordPress content changes, previews drafts using JWT authentication and passes Yoast SEO data through GraphQL into the page metadata. It is a useful reference for how many moving parts a production setup involves.
The Benefits of Combining WordPress and Next.js
Speed and a better user experience
Because pages can be pre-rendered and cached, visitors often receive content faster than they would from a page assembled on every request. That can help Core Web Vitals, although a fast result still depends on good images, lean JavaScript and sensible hosting. Headless is not automatically fast.
Complete front-end freedom
You are no longer limited by a theme. Designers and developers can build the interface with React components, modern tooling and design systems, and reuse those components across pages.
A familiar editing experience
Content teams keep the WordPress dashboard they already know, including the block editor, media library, roles and custom fields. They do not have to learn a new content system.
One content source for many channels
Because content is available through an API, the same WordPress back end can feed a website, a mobile app or a kiosk without duplicating content.
A smaller public attack surface
When the public site is a separate application, the WordPress admin can sit on a different, restricted address. This can reduce exposure, but it does not remove the need to keep WordPress, plugins and servers updated.
The Trade-Offs You Should Not Ignore
This is the part that is often missing from enthusiastic blog posts. When you replace the WordPress theme with a separate front end, anything that relied on the theme or on front-end plugin output must be rebuilt or replaced.
- Plugins that render on the front end: contact forms, sliders, search, comments, cookie banners and many SEO features do not appear automatically.
- Page builders: tools such as Elementor or Beaver Builder design pages for a WordPress theme, so they do not translate directly into a Next.js front end.
- WooCommerce: product data can be fetched through an API, but cart, checkout and account pages need careful engineering.
- Previews and redirects: previews, redirects, sitemaps and metadata all need to be implemented deliberately.
- Two systems to run: you now host, secure, monitor and update both WordPress and a Node.js application.
- Higher cost and skill requirements: the project needs developers comfortable with PHP, JavaScript, React and APIs.
WordPress Alone vs WordPress and Next.js
| Factor | Traditional WordPress | WordPress + Next.js |
|---|---|---|
| Setup effort | Low to moderate | High |
| Front-end flexibility | Limited by theme and plugins | Very high |
| Plugin compatibility | Works out of the box | Front-end features must be rebuilt |
| Editing and preview | Built in | Needs custom preview setup |
| Hosting | One WordPress host | WordPress host plus a Next.js host |
| Maintenance | One system | Two systems |
| Best for | Blogs, business sites, most small projects | Large, custom or multi-channel projects |
A Simple Example of the Connection
The code below shows the basic idea. Next.js requests the latest posts from WPGraphQL and tags the request so it can be refreshed later. Treat it as a starting point rather than production code, because caching APIs change between Next.js versions, particularly if you enable Cache Components. Always check the current Next.js documentation for your version.
// lib/wp.ts
export async function getPosts() {
const res = await fetch(process.env.WP_GRAPHQL_URL!, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: `{ posts(first: 10) { nodes { title slug excerpt date } } }`,
}),
next: { tags: ['wordpress'] },
})
const json = await res.json()
return json.data.posts.nodes
} Next, a route handler lets WordPress tell Next.js that content has changed. According to the Next.js documentation, calling revalidateTag with the 'max' profile serves stale content immediately while fresh content is generated in the background, which suits blog posts well.
// app/api/revalidate/route.ts
import { revalidateTag } from 'next/cache'
import { NextRequest, NextResponse } from 'next/server'
export async function POST(request: NextRequest) {
if (request.headers.get('x-revalidate-secret') !== process.env.REVALIDATE_SECRET) {
return NextResponse.json({ message: 'Invalid secret' }, { status: 401 })
}
revalidateTag('wordpress', 'max')
return NextResponse.json({ revalidated: true })
} Finally, a few lines of PHP, ideally placed in a small custom plugin, notify Next.js whenever a post is published or updated.
add_action( 'save_post', function ( $post_id, $post ) {
if ( wp_is_post_revision( $post_id ) || 'publish' !== $post->post_status ) {
return;
}
wp_remote_post( NEXT_REVALIDATE_URL, array(
'headers' => array( 'x-revalidate-secret' => NEXT_REVALIDATE_SECRET ),
'timeout' => 5,
'blocking' => false,
) );
}, 10, 2 ); Define the two constants in wp-config.php and keep the secret out of your public code. If you are new to connecting a JavaScript front end to WordPress, our guide on how to implement ReactJS and WordPress together covers the fundamentals.
Tools Worth Knowing
- WPGraphQL: the most widely used way to expose WordPress content through GraphQL.
- REST API: already included in WordPress and often enough for simpler projects.
- Faust.js: a headless WordPress framework created by WP Engine that works with Next.js. Check its current maintenance status and documentation before building on it.
- Advanced Custom Fields: a popular way to model structured content that your front end can query.
When WordPress and Next.js Makes Sense
- You need a highly custom interface that a theme cannot deliver.
- Your team already works in React and Next.js.
- The same content must power a website and other channels.
- Performance and scalability justify a larger budget.
- Editors need to keep a familiar content workflow.
When You Should Stay with Traditional WordPress
- You run a blog, portfolio or small business website.
- You depend heavily on plugins and page builders.
- You have no developer available for ongoing maintenance.
- Your budget is limited or your site changes shape often.
A well-built traditional WordPress site with good hosting, caching and lightweight design can be fast enough for the large majority of projects.
Need Help Deciding or Building It?
Choosing an architecture is easier with someone who has built both kinds of sites. As a freelance web developer experienced in WordPress, WooCommerce, REST API integrations and custom plugins, I can help you evaluate whether WordPress and Next.js suits your project, build the connection between the two, or improve a traditional WordPress site so that it performs the way you need. You are welcome to reach out through LinkedIn to discuss your project.
Frequently Asked Questions
Is WordPress and Next.js better than traditional WordPress?
Not in every case. It offers more front-end freedom and can deliver excellent performance, but it adds complexity, cost and maintenance. For many websites, traditional WordPress remains the better choice.
Do I need WPGraphQL to use Next.js with WordPress?
No. Next.js can read data through the built-in WordPress REST API. WPGraphQL is popular because it lets you request exactly the fields you need, but it is optional.
Can I still use WordPress plugins with a Next.js front end?
Plugins that work in the dashboard, such as Advanced Custom Fields or an SEO plugin that stores data, can still be used. Plugins that output something on the front end will not appear on the Next.js site unless you rebuild that feature there.
Is headless WordPress good for SEO?
It can be, because pages can be pre-rendered with clean HTML. However, you must recreate metadata, sitemaps, redirects and structured data yourself, so good SEO depends on careful implementation.
Final Thoughts
WordPress and Next.js is not a replacement for WordPress as we know it. It is a powerful additional pattern for projects that need custom front ends, multi-channel content or a React-based workflow. If your needs are simpler, the traditional approach is faster to build, easier to maintain and still very capable. Match the architecture to the problem, not to the trend.
