Skip to content

Upgrade Guide

Getting Started

Upgrade Guide for v3.0

You can find the legacy docs for Inertia.js v2.0 at inertiajs.com/docs/v2.

What's New

Inertia.js v3.0 is a major release focused on simplicity and developer experience. Axios has been replaced with a built-in XHR client for a smaller bundle, SSR now works out of the box during development without a separate Node.js server, and the new @inertiajs/vite plugin handles page resolution and SSR configuration automatically. This release also introduces standalone HTTP requests via the useHttp hook, optimistic updates with automatic rollback, layout props for sharing data between pages and layouts, and improved exception handling.

This release also includes several additional improvements:

Upgrade Dependencies

To upgrade to Inertia.js v3.0, first use npm to install the client-side adapter of your choice:

1npm install @inertiajs/vue3@^3.0
1npm install @inertiajs/vue3@^3.0
1npm install @inertiajs/react@^3.0
1npm install @inertiajs/react@^3.0
1npm install @inertiajs/svelte@^3.0
1npm install @inertiajs/svelte@^3.0

You may also install the new optional Vite plugin, which provides a simplified SSR setup and a pages shorthand for component resolution:

1npm install @inertiajs/vite@^3.0
1npm install @inertiajs/vite@^3.0

Next, if you are using Laravel PHP, upgrade the inertiajs/inertia-laravel package:

1composer require inertiajs/inertia-laravel:^3.0
1composer require inertiajs/inertia-laravel:^3.0

After upgrading, republish the Inertia configuration file since it has been restructured in v3. You should review the updated config file and re-apply any customizations:

1php artisan vendor:publish --provider="Inertia\\ServiceProvider" --force
1php artisan vendor:publish --provider="Inertia\\ServiceProvider" --force

You should also clear your cached views since the @inertia Blade directive output has changed:

1php artisan view:clear
1php artisan view:clear

Breaking Changes


Requirements

PHP 8.2+ and Laravel 11+

The Laravel PHP adapter now requires PHP 8.2 and Laravel 11 at a minimum.

React 19+

The React adapter now requires React 19. React 18 and below are no longer supported.

Svelte 5+

The Svelte adapter now requires Svelte 5. Svelte 4 and below are no longer supported. All Svelte code should be updated to use Svelte 5's runes syntax ($props(), $state(), $effect(), etc).

Axios Removed

Inertia no longer ships with or requires Axios. For most applications, this requires no changes. The built-in XHR client supports interceptors as well, so Axios interceptors may be migrated directly. You may also continue using Axios via the Axios adapter, or provide a fully custom HTTP client.

qs Dependency Removed

The qs package has been replaced with a built-in query string implementation and is no longer included as a dependency of @inertiajs/core. Inertia's internal query string handling remains the same, but you should install qs directly if your application imports it.

1npm install qs
1npm install qs

lodash-es Dependency Removed

The lodash-es package has been replaced with es-toolkit and is no longer included as a dependency of @inertiajs/core. You should install lodash-es directly if your application imports it.

1npm install lodash-es
1npm install lodash-es

Event Renames

Two global events have been renamed for clarity:

v2 Name v3 Name Document Event
invalid httpException inertia:httpException
exception networkError inertia:networkError

Global event listeners should be updated accordingly:

1// Before (v2)
2router.on('invalid', (event) => { ... })
3router.on('exception', (event) => { ... })
4 
5// After (v3)
6router.on('httpException', (event) => { ... })
7router.on('networkError', (event) => { ... })
1// Before (v2)
2router.on('invalid', (event) => { ... })
3router.on('exception', (event) => { ... })
4 
5// After (v3)
6router.on('httpException', (event) => { ... })
7router.on('networkError', (event) => { ... })

You may also handle these events per-visit using the new onHttpException and onNetworkError callbacks:

1router.post('/users', data, {
2 onHttpException: (response) => { ... },
3 onNetworkError: (error) => { ... },
4})
1router.post('/users', data, {
2 onHttpException: (response) => { ... },
3 onNetworkError: (error) => { ... },
4})

Returning false from the onHttpException callback or calling event.preventDefault() on the global httpException event will prevent Inertia from navigating to the error page. This allows you to handle HTTP exceptions (4xx and 5xx responses) without leaving the current page.

1router.post('/users', data, {
2 onHttpException: (response) => {
3 // Handle the error without navigating
4 return false
5 },
6})
1router.post('/users', data, {
2 onHttpException: (response) => {
3 // Handle the error without navigating
4 return false
5 },
6})

router.cancel() Replaced

The router.cancel() method has been replaced by router.cancelAll(). In v2, cancel() only canceled synchronous requests. The new cancelAll() method cancels all synchronous, asynchronous, and prefetch requests by default. You may pass options to limit which request types are canceled.

1// Before (v2) — only canceled sync requests
2router.cancel()
3 
4// After (v3) — cancels all request types
5router.cancelAll()
6 
7// To match v2 behavior (sync only)...
8router.cancelAll({ async: false, prefetch: false })
1// Before (v2) — only canceled sync requests
2router.cancel()
3 
4// After (v3) — cancels all request types
5router.cancelAll()
6 
7// To match v2 behavior (sync only)...
8router.cancelAll({ async: false, prefetch: false })

See the visit cancellation documentation for more details.

Future Options Removed

The future configuration namespace has been removed. All four future options from v2 are now always enabled and no longer configurable:

  • future.preserveEqualProps
  • future.useDataInertiaHeadAttribute
  • future.useDialogForErrorModal
  • future.useScriptElementForInitialPage
1// Before (v2)
2createInertiaApp({
3 defaults: {
4 future: {
5 preserveEqualProps: true,
6 useDataInertiaHeadAttribute: true,
7 useDialogForErrorModal: true,
8 useScriptElementForInitialPage: true,
9 },
10 },
11})
12 
13// After (v3) - just remove the `future` block
14createInertiaApp({
15 // ...
16})
1// Before (v2)
2createInertiaApp({
3 defaults: {
4 future: {
5 preserveEqualProps: true,
6 useDataInertiaHeadAttribute: true,
7 useDialogForErrorModal: true,
8 useScriptElementForInitialPage: true,
9 },
10 },
11})
12 
13// After (v3) - just remove the `future` block
14createInertiaApp({
15 // ...
16})

Initial page data is now always passed via a <script type="application/json"> element. The legacy data-page attribute approach is no longer supported.

Head Element Attributes

The inertia attribute used on elements in your root template's <head> section has been renamed to data-inertia. You should update any head elements that use this attribute:

1<!-- Before (v2) -->
2<title inertia>My Website</title>
3 
4<!-- After (v3) -->
5<title data-inertia>My Website</title>
1<!-- Before (v2) -->
2<title inertia>My Website</title>
3 
4<!-- After (v3) -->
5<title data-inertia>My Website</title>

Progress Indicator Exports Removed

The named exports hideProgress() and revealProgress() have been removed. If needed, use the progress object directly:

1import { progress } from '@inertiajs/vue3'
2 
3progress.hide()
4progress.reveal()
1import { progress } from '@inertiajs/vue3'
2 
3progress.hide()
4progress.reveal()

Deferred Component Behavior (React)

The React <Deferred> component no longer resets to show the fallback during partial reloads. Previously, the fallback was shown each time a partial reload was triggered. Now the existing content remains visible while new data loads, consistent with the Vue and Svelte behavior.

A new reloading slot prop is available across all adapters, allowing you to show a loading indicator during partial reloads while keeping the existing content visible. See the deferred props documentation for details.

Form Processing Reset Timing

The useForm helper now only resets processing and progress state in the onFinish callback, rather than immediately upon receiving a response. This ensures the processing state remains true until the visit is fully complete.

LazyProp Removed

In Laravel PHP, the Inertia::lazy() method and LazyProp class, deprecated in v2, have been removed. Use Inertia::optional() instead, which provides the same functionality:

1// Before (v2)
2return Inertia::render('Users/Index', [
3 'users' => Inertia::lazy(fn () => User::all()),
4]);
5 
6// After (v3)
7return Inertia::render('Users/Index', [
8 'users' => Inertia::optional(fn () => User::all()),
9]);
1// Before (v2)
2return Inertia::render('Users/Index', [
3 'users' => Inertia::lazy(fn () => User::all()),
4]);
5 
6// After (v3)
7return Inertia::render('Users/Index', [
8 'users' => Inertia::optional(fn () => User::all()),
9]);

Config File Restructuring

The Laravel PHP configuration file has been restructured. Page-related settings are now nested under pages, and the testing section has been simplified:

1// Before (v2) - config/inertia.php
2'testing' => [
3 'ensure_pages_exist' => true,
4 'page_paths' => [resource_path('js/Pages')],
5 'page_extensions' => ['js', 'jsx', 'svelte', 'ts', 'tsx', 'vue'],
6],
7 
8// After (v3) - config/inertia.php
9'pages' => [
10 'ensure_pages_exist' => false,
11 'paths' => [resource_path('js/Pages')],
12 'extensions' => ['js', 'jsx', 'svelte', 'ts', 'tsx', 'vue'],
13],
14 
15'testing' => [
16 'ensure_pages_exist' => true,
17],
1// Before (v2) - config/inertia.php
2'testing' => [
3 'ensure_pages_exist' => true,
4 'page_paths' => [resource_path('js/Pages')],
5 'page_extensions' => ['js', 'jsx', 'svelte', 'ts', 'tsx', 'vue'],
6],
7 
8// After (v3) - config/inertia.php
9'pages' => [
10 'ensure_pages_exist' => false,
11 'paths' => [resource_path('js/Pages')],
12 'extensions' => ['js', 'jsx', 'svelte', 'ts', 'tsx', 'vue'],
13],
14 
15'testing' => [
16 'ensure_pages_exist' => true,
17],

The updated config file should have already been republished as part of the upgrade dependencies step above.

Testing Concerns Removed

In Laravel PHP, the deprecated Inertia\Testing\Concerns\Has, Inertia\Testing\Concerns\Matching, and Inertia\Testing\Concerns\Debugging traits have been removed. These traits were deprecated in v1 and replaced by the AssertableInertia class. No action is required unless your application references these traits directly.

React Arrow Function Layout Components

The new layout implementation in v3 no longer supports arrow function components assigned directly to .layout. Inertia cannot reliably distinguish them from render functions at runtime. Wrapping the component in an array resolves this:

1const Layout = ({ children }) => <main>{children}</main>
2 
3// ❌ does not work — arrow function component assigned directly
4Dashboard.layout = Layout
5 
6// ✅ wrap in an array instead
7Dashboard.layout = [Layout]
1const Layout = ({ children }) => <main>{children}</main>
2 
3// ❌ does not work — arrow function component assigned directly
4Dashboard.layout = Layout
5 
6// ✅ wrap in an array instead
7Dashboard.layout = [Layout]

Function declaration components continue to work without any changes.

Other Changes


Blade Components

For Laravel PHP applications, Inertia now provides <x-inertia::head> and <x-inertia::app> Blade components as an alternative to the @inertiaHead and @inertia directives. The head component accepts fallback content via its slot that only renders when SSR is not active, solving the long-standing issue of duplicate <title> tags in SSR applications.

resources/views/app.blade.php
1<html>
2 <head>
3 @vite('resources/js/app.js')
4 <x-inertia::head>
5 <title>{{ config('app.name') }}</title>
6 </x-inertia::head>
7 </head>
8 <body>
9 <x-inertia::app />
10 </body>
11</html>
1<html>
2 <head>
3 @vite('resources/js/app.js')
4 <x-inertia::head>
5 <title>{{ config('app.name') }}</title>
6 </x-inertia::head>
7 </head>
8 <body>
9 <x-inertia::app />
10 </body>
11</html>

The existing directives continue to work and require no changes.

SSR in Development

When using the new @inertiajs/vite plugin, SSR works automatically during development by simply running npm run dev. You no longer need to build your SSR bundle with vite build --ssr or start a separate Node.js server with php artisan inertia:start-ssr during development. These commands are now only required for production deployments.

Middleware Priority

In Laravel PHP, the Inertia middleware is now automatically registered in Laravel's middleware priority list, ensuring it runs before middleware like ThrottleRequests. This fixes an issue where PUT/PATCH/DELETE requests that were rate-limited could receive a 302 redirect instead of the correct 303, causing the browser to retry the original request method on the redirect target. No action is required.

Nested Prop Types

In Laravel PHP, prop types like Inertia::optional(), Inertia::defer(), and Inertia::merge() now work inside closures and nested arrays. Inertia resolves them at any depth and uses dot-notation paths in partial reload metadata.

1return Inertia::render('Dashboard', [
2 'auth' => fn () => [
3 'user' => Auth::user(),
4 'notifications' => Inertia::defer(fn () => Auth::user()->unreadNotifications),
5 'invoices' => Inertia::optional(fn () => Auth::user()->invoices),
6 ],
7]);
1return Inertia::render('Dashboard', [
2 'auth' => fn () => [
3 'user' => Auth::user(),
4 'notifications' => Inertia::defer(fn () => Auth::user()->unreadNotifications),
5 'invoices' => Inertia::optional(fn () => Auth::user()->invoices),
6 ],
7]);

On the client side, the only and except options, as well as the Deferred and WhenVisible components, all support dot-notation for targeting nested props.

1router.reload({ only: ['auth.notifications'] })
1router.reload({ only: ['auth.notifications'] })

Classes implementing the ProvidesInertiaProperties interface also work at any nesting level.

1return Inertia::render('Dashboard', [
2 'auth' => [
3 new AuthProps,
4 'team' => 'Inertia',
5 ],
6]);
1return Inertia::render('Dashboard', [
2 'auth' => [
3 new AuthProps,
4 'team' => 'Inertia',
5 ],
6]);

ES2022 Build Target

Inertia packages now target ES2022, up from ES2020 in v2. You may use the @vitejs/plugin-legacy Vite plugin if your application needs to support older browsers.

ESM-Only Packages

All Inertia packages now ship as ES Modules only. CommonJS require() imports are no longer supported. You should update any require() calls to use import statements instead.

Page Object Changes

The clearHistory and encryptHistory properties in the page object are now optional and only included in the response when true. Previously, every response included "clearHistory": false and "encryptHistory": false even when history wasn't being cleared or encrypted.