Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Setup & site building · Info

Can You Use React with WordPress? The Short Answer

Can You Use React with WordPress? The Short Answer

Short answer

Yes, you can use React with WordPress. The block editor is itself built with React, so you can write custom blocks and admin screens in React, mount a React app inside a page, or run WordPress headless and build the whole front end in React with the REST API or GraphQL.

Key takeaways

  • WordPress ships React for the block editor through the @wordpress/element package.
  • Custom blocks are the most WordPress-friendly way to use React.
  • Saved blocks render as static HTML, so React does not run on the front end by default.
  • Headless WordPress uses a separate React front end, often built with Next.js.
  • Headless gives full control but loses most theme and front-end plugin features.

Can you use React with WordPress?

Yes, React works with WordPress in three main ways: building blocks for the block editor, adding React apps to pages or admin screens, and using WordPress as a headless back end for a React front end.

WordPress already uses React. The block editor, also called Gutenberg, is a large React application, and WordPress ships React with every install for the editor to use.

That means you do not need to fight WordPress to use React. The real question is which approach fits your project, since each one has different trade-offs for SEO, hosting and plugin support.

ApproachWhat React doesPlugins and themes still work?Best for
Custom blocksPowers the editing interfaceYesCustom content components
React app inside a pageRuns one interactive widgetYesCalculators, dashboards, tools
React admin screensBuilds plugin settings pagesYesPlugin developers
Headless front endRenders the whole siteFront-end features mostly noCustom apps, high-traffic sites

How does WordPress itself use React?

The block editor is written in React, and WordPress exposes it through the @wordpress/element package, a thin layer over React that plugins can rely on.

When you write a block, you import components from WordPress packages rather than bundling your own copy of React. The @wordpress/element package gives you createElement, useState, useEffect and the other React APIs.

Using the shared copy matters. If every plugin bundled its own React, admin pages would load several copies and clash. WordPress registers React as a script handle that plugins list as a dependency.

The React documentation still applies to almost everything you write. Hooks, components and JSX work the same way inside WordPress.

How do you build custom blocks with React?

Run npx @wordpress/create-block to scaffold a block plugin, then write the block's edit and save functions in React using WordPress components.

  1. Install Node.js and npm on your computer
  2. Run the create-block command in your plugins folder
  3. Edit the generated edit.js file to build the editing interface
  4. Edit save.js to set the HTML saved to the post
  5. Run the build script and activate the plugin

The scaffold includes @wordpress/scripts, which handles JSX, bundling and dependencies for you. The Block Editor Handbook covers each file and option.

Blocks are the most WordPress-friendly way to use React. Content stays in the normal editor, works with any block theme, and does not need a separate front-end host.

Our guide on how to create a custom block in WordPress goes through a complete example.

Does React run on the front end of a normal WordPress site?

Not by default; saved blocks become static HTML on the front end, so React only runs there if you load your own script or use dynamic blocks with front-end JavaScript.

This surprises many developers. The React code in a block's edit function only runs inside the editor. Visitors see the HTML from the save function or from PHP rendering.

For interactive front-end behaviour, WordPress now offers the Interactivity API. It is not React, but it gives blocks reactive state with a small footprint. Our guide on using the Interactivity API in WordPress explains how it differs.

You can still mount a full React app on the front end. Enqueue your script with wp-element as a dependency, print an empty div with an ID in a block or shortcode, and render into it.

How do you add a React app to a WordPress page?

Build the app with @wordpress/scripts or your own bundler, enqueue the output script in a plugin, and render it into a container element placed with a shortcode or block.

This approach suits single interactive tools, such as a mortgage calculator, a quiz or a product configurator. The rest of the page stays as normal WordPress content.

Load the script only on pages that need it. Enqueueing a large bundle on every page slows the whole site. Our guide on adding JavaScript to WordPress covers conditional loading.

Pass data from PHP to React with wp_add_inline_script or by fetching from the REST API. For logged-in actions, include a nonce so WordPress can verify the request.

Can you build plugin admin pages with React?

Yes, many plugins now build their settings screens in React using WordPress components, which gives them the same look as the block editor.

Register an admin menu page in PHP that outputs an empty div, then enqueue a script that renders your React app into it. The @wordpress/components package provides buttons, panels, toggles and form controls.

Save settings through the REST API with the @wordpress/api-fetch package. It handles authentication and nonces for you.

What is headless WordPress with React?

Headless WordPress uses WordPress only to manage content, while a separate React front end, often built with Next.js, fetches that content through the REST API or GraphQL and renders the site.

The front end lives on its own host, such as a Node.js server or an edge platform. WordPress stays behind it as a content back end that editors log in to as usual.

Content is fetched from the WordPress REST API or from GraphQL with the free WPGraphQL plugin. Our guide on using the WordPress REST API shows how requests and responses look.

Frameworks such as Next.js handle routing, server rendering and static generation. Server rendering matters for SEO, because search engines then receive full HTML.

For a step-by-step setup, read our guide on how to build a headless WordPress site.

What are the downsides of headless React with WordPress?

Headless sites lose most theme and front-end plugin features, need two systems to host and maintain, and require developer time for things WordPress normally does for free.

  • Plugins: SEO, forms, sliders and page builders that output front-end HTML do not work automatically.
  • Previews: post previews and drafts need extra work to show in the React front end.
  • Hosting: you pay for and maintain two environments.
  • Editors: content teams lose visual editing unless you build it back.
  • Cost: every feature becomes custom development.

Headless makes sense for apps, large content platforms and teams with front-end developers. For a typical business site or blog, a normal theme is faster to build and easier to run. Our comparison of headless WordPress vs traditional weighs the trade-offs.

Which React approach should you choose?

Choose custom blocks for editor features, a mounted React app for one interactive tool, and headless only when you need a fully custom front end and have developers to maintain it.

Start small if you are unsure. A single block or embedded app lets you use React without giving up themes, plugins and the editing experience your team knows.

You can also combine approaches. Many headless projects still use custom blocks so editors get structured content that the React front end renders cleanly.

What skills do you need to use React with WordPress?

You need JavaScript and React basics, a working knowledge of PHP for registering scripts and blocks, and familiarity with Node.js tooling such as npm and build scripts.

The WordPress side involves hooks, script registration and REST endpoints. Our guide on creating a custom REST API endpoint covers a common next step.

Set up a local development site first. Testing builds on a live site risks breaking pages for visitors.

Frequently asked questions

Is WordPress built with React?

Partly. The block editor and many admin screens are built with React, while the core of WordPress, including themes, plugins and page rendering, still runs on PHP. WordPress loads React mainly inside the admin area.

Do I need to know React to use WordPress?

No. Site owners and most theme users never touch React. You only need it if you want to build custom blocks, React-based plugin screens or a headless front end for your WordPress content.

Can I use Next.js with WordPress?

Yes. Next.js is a common choice for headless WordPress. It fetches posts and pages from the REST API or WPGraphQL and renders them on the server, which keeps pages fast and readable for search engines.

Should I bundle my own copy of React in a WordPress plugin?

Usually not. Declare wp-element or the React script handle as a dependency so your code uses the copy WordPress already loads. Bundling a second copy increases page weight and can cause errors with hooks.

Is headless WordPress good for SEO?

It can be, if the front end renders HTML on the server or builds static pages. Client-only React apps are harder for search engines to read, and you must rebuild meta tags and sitemaps that SEO plugins normally handle.

Sources

  1. Block Editor Handbook WordPress Developer Resources
  2. @wordpress/element WordPress Developer Resources
  3. REST API Handbook WordPress Developer Resources
  4. React documentation React
  5. Next.js documentation Vercel
  6. WPGraphQL WPGraphQL

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.