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

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
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
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
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
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
Get expert guidance in a few days with a Laravel code review logo

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

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
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
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
PhpStorm logo

PhpStorm

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

PhpStorm

The latest

View all →
Laravel Schema Sentinel: Detect and Fix Database Schema Drift image

Laravel Schema Sentinel: Detect and Fix Database Schema Drift

Read article
Laravel Web Push Notifications image

Laravel Web Push Notifications

Read article
RedBerry to Host Georgia's First Laravel Meetup in Tbilisi image

RedBerry to Host Georgia's First Laravel Meetup in Tbilisi

Read article
Interruptible Jobs in Laravel 13.7.0 image

Interruptible Jobs in Laravel 13.7.0

Read article
A Free Shift to Check If Your App is Ready for Laravel Cloud image

A Free Shift to Check If Your App is Ready for Laravel Cloud

Read article
Laravel Idempotency: HTTP Idempotency Middleware for Laravel image

Laravel Idempotency: HTTP Idempotency Middleware for Laravel

Read article