# Inertia

> Connect Yii requests, responses, views, sessions, and redirects to the Inertia protocol

_Connect Yii requests, responses, views, sessions, and redirects to the Inertia protocol_

## Architecture

[`php-forge/inertia`](https://github.com/php-forge/inertia) owns the Inertia protocol, page model, prop resolution,
headers, redirects, and result objects. This package connects that core to Yii requests, responses, views, and sessions.
The application supplies its JavaScript client, component resolver, and asset build.

## Installation

Yii 2.0.x is outside this package's declared support.

```bash
composer require yii2-extensions/inertia:^0.6
```

See the [installation guide](/docs/extensions/inertia/installation/index.md) for Yii development-line resolution, bootstrap registration,
CSRF configuration, and frontend setup.

## Quick start

Register the adapter in the existing web application configuration:

```php
'bootstrap' => [\yii\inertia\Bootstrap::class],
```

Return a page from an existing controller action:

```php
return \yii\inertia\Inertia::render('Dashboard', ['stats' => ['visits' => 42]]);
```

A normal visit renders HTML; an Inertia visit returns a JSON page. The default view supplies the page payload but
loads no frontend bundle. Continue with [configuration](/docs/extensions/inertia/configuration/index.md) and the
[usage examples](/docs/extensions/inertia/examples/index.md) to connect the application's client.

## Documentation

Practical guides and application recipes, with exact contracts in PHPDoc.

- 📚 [Installation guide](/docs/extensions/inertia/installation/index.md): Composer, bootstrap, CSRF, and frontend setup.
- ⚙️ [Configuration and adapter reference](/docs/extensions/inertia/configuration/index.md): manager options, props, root views, and responses.
- 💡 [Usage examples](/docs/extensions/inertia/examples/index.md): controllers, prop recipes, validation, and redirects.
- 🔄 [Migration guide](/docs/extensions/inertia/migration/index.md) and [upgrade checklist](https://github.com/yii2-extensions/inertia/blob/main/UPGRADE.md): application changes for existing installations.
- 🧪 [Testing guide](/docs/extensions/inertia/testing/index.md): PHPUnit, static analysis, mutation, and documentation checks.

## AI assistance

AI agents: use the repository guides and package skill below. When hosted documentation is available, start at
`https://yii2-framework.github.io/docs/llms.txt` and fetch a listed page's Markdown by appending `index.md` to its URL.

For the Yii 22 conventions this package builds on, use the `yii2-framework` agent skill from a local
`yii2-framework/docs` checkout (`skills/yii2-framework/SKILL.md`).

- 🤖 [yii2-inertia-integration skill](/docs/extensions/inertia/agents/index.md): installation for Claude Code, Codex, and OpenCode.

If hosted sources are unavailable, use the [repository guides](#documentation) and the
[locally available package skill](https://github.com/yii2-extensions/inertia/blob/main/skills/yii2-inertia-integration/SKILL.md).

## Our social networks

[Follow on X](https://x.com/Terabytesoftw)
[Follow on Facebook](https://www.facebook.com/wilmer.arambula.9)
[Join our Subreddit](https://www.reddit.com/r/Yii2/)
[Join on Telegram](https://t.me/yii_framework_in_english)

## License

[License](https://github.com/yii2-extensions/inertia/blob/main/LICENSE)

## Package

- Source code and issues: [yii2-extensions/inertia](https://github.com/yii2-extensions/inertia). Star the repository if the package is useful to you.
- Composer package: [yii2-extensions/inertia](https://packagist.org/packages/yii2-extensions/inertia).
- Changelog: [CHANGELOG.md](https://github.com/yii2-extensions/inertia/blob/main/CHANGELOG.md).