PHPackages                             webkulwp/inertia - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. webkulwp/inertia

ActiveLibrary

webkulwp/inertia
================

Inertia.js server-side adapter for PHP. Handles full visits, Inertia XHR visits, asset-version 409 handshakes and partial reloads. Framework-agnostic, with transparent WordPress integration.

v1.0.2(1mo ago)145↓75%MITPHPPHP &gt;=7.4

Since Jul 15Pushed 1mo agoCompare

[ Source](https://github.com/webkul/inertia)[ Packagist](https://packagist.org/packages/webkulwp/inertia)[ RSS](/packages/webkulwp-inertia/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

webkul/inertia
==============

[](#webkulinertia)

Inertia.js server-side adapter for **PHP** — the equivalent of what `inertia-laravel` provides on Laravel, for any plain-PHP application.

It is framework-agnostic: everything runs on native PHP. When WordPress is loaded, its helpers (`wp_json_encode`, `status_header`, `sanitize_text_field`, `wp_head` / `wp_footer` in the default shell, the `blog_charset` option, …) are picked up automatically — no configuration needed.

It handles the full Inertia protocol:

- **First / standard visit** → full HTML document with the page object embedded in a JSON script tag (`script[data-page=""][type="application/json"]`, the Inertia v3 convention).
- **Inertia visit** (XHR with `X-Inertia: true`) → bare JSON page object, no HTML, so the client swaps props without a page reload.
- **Stale assets** (`X-Inertia-Version` mismatch on GET) → `409` + `X-Inertia-Location`, telling the client to do one hard reload to pick up new bundles.
- **Partial reloads** → prop filtering via `X-Inertia-Partial-Data` / `X-Inertia-Partial-Except`, with closure props resolved lazily *after*filtering so skipped props cost no queries.

Installation
------------

[](#installation)

```
composer require webkul/inertia
```

While the package lives inside a project as a path repository, add to the project's `composer.json`:

```
{
    "repositories": [
        { "type": "path", "url": "packages/inertia" }
    ],
    "require": {
        "webkul/inertia": "@dev"
    }
}
```

Usage
-----

[](#usage)

### Plain PHP

[](#plain-php)

```
use Webkul\Inertia\Inertia;

$inertia = Inertia::instance()
    ->set_version( '1.0.0' )   // string or callable, e.g. a build hash
    ->set_app_id( 'app' );     // container / script id for the default shell

$inertia->render( 'Order', array(
    'orders'  => fn() => fetch_orders(), // lazy: skipped on partial reloads
    'filters' => $filters,
) );
```

### WordPress (custom HTML shell)

[](#wordpress-custom-html-shell)

```
use Webkul\Inertia\Inertia;

$inertia = Inertia::instance()
    ->set_version( MY_PLUGIN_SCRIPT_VERSION )
    ->set_root_view( array( My_Template::instance(), 'render_ui_template' ) );

if ( ! $inertia->is_inertia_request() ) {
    // Assets are only needed for the HTML shell, not for JSON visits.
    my_plugin_enqueue_app_assets();
}

$inertia->render( 'Order', $props );
```

`render()` always terminates the request.

### Configuration

[](#configuration)

MethodPurpose`set_version( string|callable $version )`Asset version used for the 409 stale-asset handshake.`set_root_view( callable $renderer )`Renderer for the HTML shell on standard visits. Receives `( string $page_json, array $page )` and must output the full document.`set_app_id( string $id )`Container / script id used by the built-in fallback shell (default `app`). Only relevant when no root view is set.`set_charset( string $charset )`Response charset (default `UTF-8`). Under WordPress the `blog_charset` option takes precedence.If no root view is configured, a minimal shell is rendered: a JSON script tag plus an empty `` — and, inside WordPress, `wp_head()` / `wp_footer()` / `body_class()` are included automatically.

Examples
--------

[](#examples)

Runnable end-to-end examples live in [`examples/`](examples/):

- [`examples/react/`](examples/react/) — client built with the official `@inertiajs/react` adapter (React 18), including SPA links and partial reloads via `router.reload({ only: [...] })`.
- [`examples/vanilla-js/`](examples/vanilla-js/) — no framework: a ~70 line hand-rolled client showing the raw protocol (boot from the JSON script tag, `fetch()` visits with `X-Inertia` headers, the 409 hard-reload handshake, partial reloads, back/forward handling).

Each folder is a standalone mini-app: `php -S localhost:8000 index.php`.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b3d19c09b89f420fac0217dbdff8be9b28ce99b04c3a1bce23c0652b5b880c5d?d=identicon)[himanshu-here](/maintainers/himanshu-here)

---

Top Contributors

[![himanshu-here](https://avatars.githubusercontent.com/u/107554896?v=4)](https://github.com/himanshu-here "himanshu-here (3 commits)")[![webkul](https://avatars.githubusercontent.com/u/519857?v=4)](https://github.com/webkul "webkul (1 commits)")

---

Tags

phpwordpressinertiainertiajsSPA

### Embed Badge

![Health badge](/badges/webkulwp-inertia/health.svg)

```
[![Health](https://phpackages.com/badges/webkulwp-inertia/health.svg)](https://phpackages.com/packages/webkulwp-inertia)
```

###  Alternatives

[nytodev/inertia-bundle

Symfony Bundle implementing the Inertia.js v3 server-side protocol

212.2k](/packages/nytodev-inertia-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
