| Install | |
|---|---|
composer require trianayulianto/inertia-codeigniter-4 |
|
| Latest Version: | v1.0.1 |
| PHP: | ^8.1 |
| License: | MIT |
| Last Updated: | Jan 17, 2026 |
| Links: | GitHub · Packagist |
You can install the package via composer:
composer require trianayulianto/inertia-codeigniter-4
app.php<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title inertia>CI4-Inertia</title>
<!-- ViteJs Helper -->
<?= vite_react_refresh() ?>
<?= vite(['resources/js/app.tsx', "resources/js/pages/{$page['component']}.tsx"]) ?>
<?= \Inertia\Directive::inertiaHead($page) ?>
</head>
<body>
<?= \Inertia\Directive::inertia($page) ?>
</body>
</html>
php spark make:filter HandleInertiaRequests
<?php
namespace App\Filters;
use CodeIgniter\Filters\FilterInterface;
use CodeIgniter\HTTP\Request;
use Inertia\Middleware;
class HandleInertiaRequests extends Middleware implements FilterInterface
{
/**
* The root template that is loaded on the first page visit.
*
* @var string
*/
protected $rootView = 'app';
/**
* Determine the current asset version.
*
* @param \CodeIgniter\HTTP\Request $request
* @return string|null
*/
public function version(Request $request)
{
return parent::version($request);
}
/**
* Define the props that are shared by default.
*
* @param \CodeIgniter\HTTP\Request $request
* @return array
*/
public function share(Request $request)
{
return array_merge(parent::share($request), []);
}
}
That's it, you're all ready to go server-side! From here you can start creating Inertia responses.
use Inertia\Inertia;
class EventsController extends Controller
{
public function show($id)
{
$event = Event::find($id);
return Inertia::render('Event/Show', [
'event' => $event,
]);
}
}
npm install @inertiajs/react
In your app.js file, import the adapter and add it to the list of adapters:
import { createInertiaApp } from '@inertiajs/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(<App {...props} />)
},
})
Visit inertiajs.com to learn more.
composer test
inertia() helper.Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.