Skip to content

Global Props

As you've probably noticed, Inertia is all about the page props.

While you can share anything you want with your frontend, we've also provided some global props to help make your life easier.

Errors

$page.props.errors

This is an object that's used by your InertiaJS Form Helper. If you're using our recommended REST API controllers for processing forms, any validation errors will be automatically returned with this object.

Flash

$page.props.flash

Flash data is short-lived information passed to your frontend that provides feedback on user actions.

This can be used for, say, showing a user a snackbar/toast message when a form has been submitted.

php
use EvoMark\InertiaWordpress\Inertia;

Inertia::flash('success', 'Thanks for your message');

WP

$page.props.wp

Common data from your Wordpress application that might be useful in various situations.

Some examples include (but are not limited to):

PropDescription
wp.nameThe name of your site
wp.homeUrlThe URL of your site's homepage
wp.restUrlThe base URL for making REST API requests
wp.userThe user object for the currently logged in user
wp.userCapabilitiesAn object of the current users capabilities/permission
wp.logoAn image resource containing your site logo as set in Wordpress' Appearance->Customise menu
wp.menusA nested object containing your registered menus, keyed by location
wp.adminBarAn array of changed HTML elements that can be updated in your admin bar
wp.noncesCommon nonces (number used once) that are sometimes needed for making requests

Released under the Apache2 License.