4,000 emails/month for free | Mailtrap sends real emails 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
Tinkerwell

Enjoy coding and debugging in an editor designed for fast feedback and quick iterations. It's like a shell for your application – but with multi-line editing, code completion, and more.

Visit Tinkerwell
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
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
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
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
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
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
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 →
Docker Support in Laravel VS Code Extension v1.4.2 image

Docker Support in Laravel VS Code Extension v1.4.2

Read article
Laravel Deadlock: Manage Technical Debt with Expiring Code Markers image

Laravel Deadlock: Manage Technical Debt with Expiring Code Markers

Read article
Filament v5 Released With Livewire v4 Support and a New Blueprint Tool image

Filament v5 Released With Livewire v4 Support and a New Blueprint Tool

Read article
Async Request Cancellation Updates in Inertia v2.3.10 image

Async Request Cancellation Updates in Inertia v2.3.10

Read article
FluentVox: AI Text-to-Speech for Laravel with Voice Cloning and GPU Acceleration image

FluentVox: AI Text-to-Speech for Laravel with Voice Cloning and GPU Acceleration

Read article
Laravel Boost v1.8.10 Released With New AI Prompts and Livewire v4 Support image

Laravel Boost v1.8.10 Released With New AI Prompts and Livewire v4 Support

Read article