Skip to main content

PHP Runtime

Role

The PHP runtime is responsible for preparing the data that the frontend uses on first render and during route fetches.

Main Files

The shared runtime lives in the ReactWP mu-plugin:

  • inc/runtime/RouteResolver.php
  • inc/runtime/MenuBuilder.php
  • inc/runtime/Bootstrap.php
  • inc/runtime/FieldGroups.php
  • inc/routes/rest.php

For the high-level role of the mu-plugin and bundled plugins, see Architecture.

RouteResolver

RouteResolver builds the normalized route payload used by the frontend.

Its job is to describe:

  • the current route
  • the template name
  • the route data
  • SEO data
  • whether the route is a 404

It also builds the optional head payload used during client-side navigation.

When a route is resolved through the REST endpoint, ReactWP applies the rwp_wp_head filter and stores the resulting tags in route.head. The frontend can then re-sync those tags after a client-side navigation.

MenuBuilder normalizes WordPress menus into a frontend-friendly shape.

Menu locations are not hardcoded in the theme. They are registered from the ReactWP site settings, which keeps the default behavior configurable from the admin.

Bootstrap

Bootstrap prepares the first-load payload injected into the page.

That payload contains:

  • site
  • theme
  • system
  • assets
  • navigation
  • route
  • seoDefaults

This is the same general contract that the frontend expects during client-side navigation.

FieldGroups

FieldGroups.php registers the runtime-side ACF fields that control:

  • media_groups
  • react_template

Those field groups are enabled for:

  • posts
  • pages
  • users
  • taxonomies
  • any extra post types selected in Site settings

REST Route

inc/routes/rest.php exposes the route endpoint used for client-side navigation:

  • reactwp/v1/route

That route returns the same normalized route shape used by the first bootstrap payload.

ReactWP also restricts REST access by default and lets public routes through rwp_allowed_rest_routes.

By default:

  • admins keep normal REST API access
  • non-admin users and guests are blocked
  • any route explicitly allowed through rwp_allowed_rest_routes stays accessible

ReactWP exposes a few runtime filters that are important when you need to customize route payloads or head tags:

  • rwp_route_payload
  • rwp_wp_head

If you need to add or change meta tags, canonical tags, Open Graph tags, or other custom head markup that must also work after React navigation, use rwp_wp_head.

For the full rwp_wp_head behavior and context payload, see Head and SEO.

For the full payload structure and the public starter filters, see: