PHPackages                             yii2-framework/inertia-react - 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. yii2-framework/inertia-react

ActiveLibrary

yii2-framework/inertia-react
============================

React adapter helpers for inertia.

2274↑1367.2%[1 PRs](https://github.com/yii2-framework/inertia-react/pulls)PHPCI passing

Since Apr 8Pushed 4d agoCompare

[ Source](https://github.com/yii2-framework/inertia-react)[ Packagist](https://packagist.org/packages/yii2-framework/inertia-react)[ RSS](/packages/yii2-framework-inertia-react/feed)WikiDiscussions main Synced 1mo ago

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

    ![Yii Framework](https://camo.githubusercontent.com/f390171a839a7620dea19acb5fc1fb87f9226e65910c577f99803347ce48336a/68747470733a2f2f7777772e7969696672616d65776f726b2e636f6d2f696d6167652f64657369676e2f6c6f676f2f796969335f66756c6c5f666f725f6c696768742e737667)

Inertia React
=============

[](#inertia-react)

 [ ![PHPUnit](https://camo.githubusercontent.com/8cf3706e62c052db65a8ded33f868012dfdbdfcd8d8090b3d2426510c5469ac9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f796969322d657874656e73696f6e732f696e65727469612d72656163742f6275696c642e796d6c3f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6162656c3d504850556e6974) ](https://github.com/yii2-extensions/inertia-react/actions/workflows/build.yml) [ ![Mutation Testing](https://camo.githubusercontent.com/27073d4c074288fdc9b1367e673bcdb339aa8dd54cc75c9c6b0cea90bb03bc3f/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666f722d7468652d62616467652675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246796969322d657874656e73696f6e73253246696e65727469612d72656163742532466d61696e) ](https://dashboard.stryker-mutator.io/reports/github.com/yii2-extensions/inertia-react/main) [ ![PHPStan](https://camo.githubusercontent.com/926e6d88f5f8b2af850c21fb9eea061bd477a59352b49d4bab4251feb37039d4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f796969322d657874656e73696f6e732f696e65727469612d72656163742f7374617469632e796d6c3f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6162656c3d5048505374616e) ](https://github.com/yii2-extensions/inertia-react/actions/workflows/static.yml)

 **React adapter helpers for [yii2-extensions/inertia](https://github.com/yii2-extensions/inertia)**
 *React-friendly root view and Vite asset integration for Yii2 Inertia applications*

Features
--------

[](#features)

  ![Feature Overview](./docs/svgs/features.svg)Overview
--------

[](#overview)

`yii2-extensions/inertia-react` is a thin PHP-side adapter package for building React-based Inertia applications on top of `yii2-extensions/inertia`.

This package does not install npm dependencies for you. Instead, it provides.

- a React-specific bootstrap class for Yii2;
- a default root view that outputs Vite tags plus the initial Inertia page payload;
- a Vite helper component for development-server and manifest-driven production assets;
- React Refresh preamble output for `@vitejs/plugin-react` in development mode;
- documentation and conventions for the application-owned React client entrypoint.

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

[](#installation)

```
composer require yii2-extensions/inertia-react:^0.1
```

Register the React bootstrap class.

```
return [
    'bootstrap' => [
        \yii\inertia\react\Bootstrap::class,
    ],
    'components' => [
        'inertiaReact' => [
            'class' => \yii\inertia\Vite::class,
            'baseUrl' => '@web/build',
            'devMode' => YII_ENV_DEV,
            'devServerUrl' => 'http://localhost:5173',
            'entrypoints' => [
                'resources/js/app.jsx',
            ],
            'manifestPath' => '@webroot/build/.vite/manifest.json',
            'preambleProvider' => \yii\inertia\react\Bootstrap::reactRefreshPreambleProvider(),
        ],
    ],
];
```

Use only `yii\inertia\react\Bootstrap::class` in the bootstrap list. It already delegates the base `yii2-extensions/inertia` bootstrap.

React client entrypoint
-----------------------

[](#react-client-entrypoint)

Install the client-side dependencies in your application project.

```
npm install react react-dom @vitejs/plugin-react @inertiajs/react vite
```

Then create your client entrypoint, for example `resources/js/app.jsx`:

```
import { createInertiaApp } from "@inertiajs/react";
import { createElement } from "react";
import { createRoot } from "react-dom/client";

createInertiaApp({
  resolve: (name) => {
    const pages = import.meta.glob("./Pages/**/*.jsx", { eager: true });
    return pages[`./Pages/${name}.jsx`];
  },
  setup({ el, App, props }) {
    createRoot(el).render(createElement(App, props));
  },
});
```

Development mode and React Refresh
----------------------------------

[](#development-mode-and-react-refresh)

When `devMode` is `true` and `preambleProvider` is set to `\yii\inertia\react\Bootstrap::reactRefreshPreambleProvider()`, the Vite helper bypasses the production manifest and emits, in order: the React Refresh preamble, `@vite/client`, and each `entrypoints` script pointing at `devServerUrl`. Edits to `.jsx` files are hot reloaded without a full page refresh.

Run the Vite dev server and the Yii2 application side by side:

```
# Terminal 1 — Vite dev server
npm run dev

# Terminal 2 — Yii2 in dev mode
YII_ENV=dev ./yii serve
```

See [Development Notes](docs/development.md) for the full HMR workflow, CORS notes, and troubleshooting.

Production asset integration
----------------------------

[](#production-asset-integration)

This package expects a Vite manifest file generated with `build.manifest = true`. In production it will render.

1. style sheet tags for the entrypoint chunk and its imported chunks;
2. module entry scripts for each entrypoint;
3. optional `modulepreload` tags for imported JavaScript chunks.

Documentation
-------------

[](#documentation)

For detailed configuration options and advanced usage.

- 📚 [Installation Guide](docs/installation.md)
- ⚙️ [Configuration Reference](docs/configuration.md)
- 💡 [Usage Examples](docs/examples.md)
- 🧪 [Testing Guide](docs/testing.md)
- 🛠️ [Development Notes](docs/development.md)

Package information
-------------------

[](#package-information)

[![PHP](https://camo.githubusercontent.com/f04357fef9ebcd99ed76d5414552bcd1ce849df0ee1d4faf8e991f54c966d508/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f253345253344382e332d3737374242342e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://www.php.net/releases/8.3/en.php)[![Yii 22.0.x](https://camo.githubusercontent.com/6419cb138fb08a8fcb971e8e780bed42fdb74f683a39b22ca0cd2059f246ce43/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f32322e302e782d3030373341412e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d796969266c6f676f436f6c6f723d7768697465)](https://github.com/yiisoft/yii2/tree/22.0)[![Latest Stable Version](https://camo.githubusercontent.com/0102a6ae49a9c5da7018fdda3396125a84094b7d58deaa3ab16bfdfac2536b13/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796969322d657874656e73696f6e732f696e65727469612d72656163742e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465266c6162656c3d537461626c65)](https://packagist.org/packages/yii2-extensions/inertia-react)[![Total Downloads](https://camo.githubusercontent.com/af4178243d45ea25e32d5965a28f4ce4ef0bc3094f2b15a6d43f475b457cd7b4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796969322d657874656e73696f6e732f696e65727469612d72656163742e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d636f6d706f736572266c6f676f436f6c6f723d7768697465266c6162656c3d446f776e6c6f616473)](https://packagist.org/packages/yii2-extensions/inertia-react)

Quality code
------------

[](#quality-code)

[![Codecov](https://camo.githubusercontent.com/3103ab1a800d21fb647c5932e0766b552146fee70087f59b3afee65779c2d1ed/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f796969322d657874656e73696f6e732f696e65727469612d72656163742e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d636f6465636f76266c6f676f436f6c6f723d7768697465266c6162656c3d436f766572616765)](https://codecov.io/github/yii2-extensions/inertia-react)[![PHPStan Level Max](https://camo.githubusercontent.com/b1aeb44257ce46737d1787123b534aab9dded28219f828e4ae13a1e3b460f53c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d61782d3446354439352e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465)](https://github.com/yii2-extensions/inertia-react/actions/workflows/static.yml)[![Super-Linter](https://camo.githubusercontent.com/fca3c68bca86ca1311b680ec55823000deebc6dabe0e6bf5ba6fc6ed73e864e4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f796969322d657874656e73696f6e732f696e65727469612d72656163742f6c696e7465722e796d6c3f7374796c653d666f722d7468652d6261646765266c6162656c3d53757065722d4c696e746572266c6f676f3d676974687562)](https://github.com/yii2-extensions/inertia-react/actions/workflows/linter.yml)[![StyleCI](https://camo.githubusercontent.com/2e44ba381d6c9ab95b548566772bd17337dc56f8a6a646974bf7277720e5be9d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5374796c6543492d5061737365642d3434434331312e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465)](https://github.styleci.io/repos/1203882767?branch=main)

License
-------

[](#license)

[![License](https://camo.githubusercontent.com/680c8d62ba2d5a71d7099b6e81114fb0b22d99086c121fd178e1149afc669d44/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4253442d2d332d2d436c617573652d627269676874677265656e2e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d6f70656e736f75726365696e6974696174697665266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d353535353535)](LICENSE)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance65

Regular maintenance activity

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/524d2b46690f41fce7188d369488a35e7624e6c5a264d82aacd08548bfd156ab?d=identicon)[terabytesoftw](/maintainers/terabytesoftw)

---

Top Contributors

[![terabytesoftw](https://avatars.githubusercontent.com/u/42547589?v=4)](https://github.com/terabytesoftw "terabytesoftw (8 commits)")

---

Tags

inertiainertiajsphpreactreact19single-page-applicationsspaviteyii2

### Embed Badge

![Health badge](/badges/yii2-framework-inertia-react/health.svg)

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

PHPackages © 2026

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