Skip to content

Installation ​

bash
composer require solophp/inertia

Requirements ​

PHP8.3 or later
HTTP messagesAny PSR-7 implementation with PSR-17 factories, such as nyholm/psr7
MiddlewareAny PSR-15 dispatcher, such as solophp/application
LoggerOptional: any PSR-3 logger, for rescued deferred props and failed server-side renders
SSROptional: any PSR-18 client, for Ssr\HttpGateway

The client ​

The package speaks the protocol of Inertia.js 3: the first page arrives in a <script data-page="app" type="application/json"> element, which clients before 3.0 do not read by default. Install the adapter of your front-end framework and, optionally, the Vite plugin:

bash
npm install @inertiajs/svelte @inertiajs/vite   # or @inertiajs/vue3, @inertiajs/react

The client-side setup of the Inertia documentation applies as it is. Everything it says about the server is done by this package instead of the Laravel adapter; the pages of this guide show the PSR way.

What is in the package ​

ClassRole
InertiaRenders pages, makes redirects, creates props with rules of their own
InertiaMiddlewareVersion conflicts, 303 after PUT/PATCH/DELETE, fragment redirects, Vary
EncryptHistoryMiddlewareEncrypts the history state of the pages below it
PrecognitionMiddlewareValidates a form while the user fills it in, without running the handler
Prop, ScrollMetadataProps with rules: always, optional, deferred, merge, once, infinite scroll
CookieFlashStoreCarries errors and flash data to the next page in a signed cookie
PhpRootViewThe HTML document of a first visit, from a PHP template
Ssr\HttpGatewayServer-side rendering with Inertia's Node SSR server
HeaderThe header names of the protocol

Next: Quick Start.

Released under the MIT License.