Tinkerwell - The PHP Scratchpad

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
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

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

Tinkerwell
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
PhpStorm logo

PhpStorm

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

PhpStorm
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
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
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

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

Shift
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
Lucky Media logo

Lucky Media

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

Lucky Media
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

The latest

View all →
Laravel Launches an Open Directory of AI Agent Skills for Laravel and PHP image

Laravel Launches an Open Directory of AI Agent Skills for Laravel and PHP

Read article
Filament turns five in style! image

Filament turns five in style!

Read article
Cache Concurrency Limiting in Laravel 12.53.0 image

Cache Concurrency Limiting in Laravel 12.53.0

Read article
Stop Failing APIs from Killing Your Queue — Fuse for Laravel image

Stop Failing APIs from Killing Your Queue — Fuse for Laravel

Read article
Blaze: An Optimized Blade Template Compiler for Laravel image

Blaze: An Optimized Blade Template Compiler for Laravel

Read article
Chief: Run Claude Code on Large Projects with Task-Based Workflows image

Chief: Run Claude Code on Large Projects with Task-Based Workflows

Read article