Skip to content

Yii2 InertiaModern single-page apps with classic Yii controllers

The Inertia.js v3 adapter for Yii 2. Build React, Vue or Svelte frontends without writing an API.

Yii2 Inertia

At a glance

php
use Crenspire\Yii2Inertia\Inertia;

class UserController extends \yii\web\Controller
{
    public function actionIndex(): \yii\web\Response
    {
        return Inertia::render('Users/Index', [
            'users' => fn () => User::find()->select(['id', 'name', 'email'])->asArray()->all(),
        ]);
    }
}
jsx
// src/pages/Users/Index.jsx
export default function Index({ users }) {
  return (
    <ul>
      {users.map((user) => <li key={user.id}>{user.name}</li>)}
    </ul>
  )
}

Continue with the introduction or jump straight to installation.

Released under the MIT License.