Laravel Cloud is here! Zero-config managed infrastructure for Laravel apps. Deploy now.

Updates to Inertia.js and the Laravel Adapter

Published on by

Updates to Inertia.js and the Laravel Adapter image

The Laravel team has released some sweet updates to Inertia.js v2 and the Laravel adapter, introducing new features, an improved developer experience, and more. A massive shout-out to Pascal Baljet, who shared the highlight features below and worked on all these features, as well as everyone else involved in working on Inertia!

Check if a Page Component Exists

Typically, when an Inertia component does not exist, it fails silently, displaying a blank page with no details about the error. Now, if you enable the inertia.ensure_pages_exist, the Laravel adapter will throw an exception if the page doesn't exist.

Let's say that you attempt to render a page component but make a typo:

Route::get('/', function () {
return Inertia::render('welcome.missing');
})->name('home');

You'll get a blank page if you accidentally make a typo or forget to create the file:

If you enable the ensure_pages_exist setting, you'll get a helpful exception message:

To see this configuration option, you might need to re-publish or update your config/inertia.php configuration file, depending on whether you used one of the Laravel starter kits or installed from scratch:

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

Important: Make sure your inertia.php config file is under version control or backed up before forcing an update.

Artisan inertia:check-ssr Command

The Inertia Laravel adapter has an inertia:check-ssr console command to check the status of the SSR server. This health check can be a useful feature to ensure server-side rendering is working as expected during or just after a deployment, as well as periodically:

Form Helper Improvement

When using the form helper, you can reset form state and clear errors using separate methods. When you want to do both, you can now call a new function to do both:

// Called separately
form.reset()
form.clearErrors()
 
// Both reset and clear
form.resetAndClearErrors()

See Pull Request #2414 in the Inertiajs/inertia project for details.

Client-side Visit Callbacks

When making a manual visit, you can now define onSuccess(), onError(), and onFinish() callbacks:

import { router } from '@inertiajs/react'
 
router.push({
props: { search: 'Laravel' },
onSuccess: (page) => {},
onError: (errors) => {},
onFinish: (visit) => {},
})

Testing Partial Reloads

When you want to test how your application responds to partial reloads, you can use the reloadOnly() and reloadExcept() methods to perform follow-up requests and assert:

$response->assertInertia(fn (Assert $page) => $page
->has('orders')
->missing('statuses')
->reloadOnly('statuses', fn (Assert $reload) => $reload
->missing('orders')
->has('statuses', 5)
)
);

See the testing partial reloads testing documentation for details.

Learn More

If you want to learn more about all the features, bugfixes, and work being done on Inertia, check the inertiajs/inertia releases and the inertiajs/inertia-laravel releases. The official documentation has details on everything covered in this update.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
SerpApi logo

SerpApi

Access real-time search engine results through a simple API—no more scraping headaches! Use it for AI applications, SEO tools, product research, travel information, and more

SerpApi
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum

The latest

View all →
Simple Feature Flags for Laravel with Laravel Toggle image

Simple Feature Flags for Laravel with Laravel Toggle

Read article
Manage Laravel Cloud Deployments Inside PhpStorm image

Manage Laravel Cloud Deployments Inside PhpStorm

Read article
Piper: Laravel-Style Array and String Helpers for PHP's Pipe Operator image

Piper: Laravel-Style Array and String Helpers for PHP's Pipe Operator

Read article
Storage Cache Store in Laravel 13.10.0 image

Storage Cache Store in Laravel 13.10.0

Read article
Laravel MongoDB Full-Text Search tutorial: The Art of the Relevancy image

Laravel MongoDB Full-Text Search tutorial: The Art of the Relevancy

Read article
Drag-and-Drop Sorting for Eloquent Models with Reorderable for Laravel image

Drag-and-Drop Sorting for Eloquent Models with Reorderable for Laravel

Read article