News

Inertia.js v3.0.0 Is Here with Optimistic Updates, useHttp, and More

Published
Inertia.js v3.0.0 Is Here with Optimistic Updates, useHttp, and More image

Inertia.js v3.0.0 is now released. We covered the beta earlier this year, and the final release ships with those features alongside a number of fixes and refinements accumulated during the beta period. The release touches the core package and all three adapters (React, Vue, and Svelte).

Key highlights:

  • Built-in XHR HTTP client replaces Axios as a required dependency
  • New useHttp hook for making non-navigation HTTP requests
  • First-class optimistic update support across the router, useForm, and useHttp
  • Layout props API replaces event bus and provide/inject workarounds
  • SSR now works in Vite development mode without a separate server process

What's New

Built-In XHR Client — Axios Now Optional

Axios is no longer a required dependency. Inertia now ships its own XHR client, which removes Axios (~15KB gzipped) from your bundle by default. If you rely on Axios interceptors or need to preserve existing behavior, Axios is still available as an optional peer dependency.

The qs package was also removed. Install it directly if your application depends on it.

PR: #2833

useHttp Hook

The new useHttp hook covers the long-standing gap for making HTTP requests that don't trigger a page navigation. It returns reactive state — processing, errors, progress, and isDirty — matching the DX of useForm. It also integrates with Precognition 2.x for real-time validation.

const http = useHttp({
query: '',
})
 
const search = () => {
http.get('/api/search').then((results) => {
console.log('Found:', results.length)
})
}

This hook is intended for routes that return response()->json(), not Inertia::render(). A withAllErrors option is also supported for returning all validation errors at once rather than the first per field.

PR: #2840, #2880

Optimistic Updates

Inertia v3 adds a first-class optimistic update API across the router, useForm, and useHttp. Changes are applied immediately to page state and automatically rolled back on non-2xx responses. Only keys explicitly defined in the callback are snapshotted. Concurrent optimistic updates are also handled — multiple in-flight requests each carry their own rollback snapshot.

// Fluent
router
.optimistic((props) => ({
todos: [...props.todos, { id: Date.now(), name, done: false }],
}))
.post('/todos', { name })
 
// Inline option
router.post('/todos', { name }, {
optimistic: (props) => ({
todos: [...props.todos, { id: Date.now(), name, done: false }],
}),
})

The <Form> component also gains an optimistic prop, and both optimistic and transform callbacks now have generic type inference.

const form = useForm({ name: '' })
 
const addTodo = () => {
form
.optimistic((props) => ({
todos: [...props.todos, { id: Date.now(), name: form.name, done: false }],
}))
.post('/todos')
}

PR: #2866, #2898, #2881

Layout Props

useLayoutProps and setLayoutProps give pages a clean way to pass data into their layout without reaching for an event bus or provide/inject. Layouts declare defaults; pages call setLayoutProps() to override them. The final implementation passes layout props directly as component props.

PR: #2859, #3005

SSR in Vite Development Mode

SSR now works during npm run dev without running a separate Node.js server process. The Vite plugin handles it automatically, and a flash-of-unstyled-content fix is included. For production, the workflow is unchanged: vite build && vite build --ssr, then php artisan inertia:start-ssr.

PR: #2864, #2911

More in v3

The following features also ship in v3.0.0. See the official documentation and upgrade guide for full details:

  • Instant Visits (#2907) — swap to the target page component immediately using shared props before the server responds; page-specific props merge in on arrival
  • createInertiaApp() without arguments (#2883) — can now be called with zero config when using the Vite plugin; a layout option and withApp callback were also added (#2884, #2949)
  • preserveFragment option (#2897, #2899) — preserve URL fragments across redirects, with server-side support in the Laravel adapter
  • preserveErrors option (#2819) — retain validation errors during partial reloads
  • <Deferred> reloading slot prop (#2860) — the component no longer resets on partial reloads; use the new slot prop to handle that state yourself
  • HttpError base class (#2999) — a typed base class for HTTP exceptions in the event system
  • Popover API progress bar (#2917) — the progress bar is rewritten using the browser's native Popover API
  • React Strict Mode (#2909) — pass strictMode: true to createInertiaApp() to enable React.StrictMode
  • Svelte 5 adapter (#2677) — rewritten with rune syntax; Svelte 4 is dropped
  • SharedPageProps in event and createInertiaApp types (#2956) — shared props are now included in the TypeScript types for events and app setup

Upgrade Notes

This is a major release with breaking changes, including updated framework version requirements, the Axios removal, ESM-only output, and a number of renamed APIs. Review the official upgrade guide for the full list before upgrading.

To upgrade:

npm install @inertiajs/vue3@^3.0 # or @inertiajs/react / @inertiajs/svelte
npm install @inertiajs/vite@^3.0
composer require inertiajs/inertia-laravel:^3.0

References

Paul Redmond photo

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

Sponsored

laravelcloud logo
Laravel Cloud

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

Visit Laravel Cloud

The latest

View all →
Validate and Convert HEIC Images in Laravel image

Validate and Convert HEIC Images in Laravel

Read article
Saga Lara Flow: Durable Workflows and Compensating Transactions on Laravel Queues image

Saga Lara Flow: Durable Workflows and Compensating Transactions on Laravel Queues

Read article
Reject Unexpected Array Keys with Laravel Validation image

Reject Unexpected Array Keys with Laravel Validation

Read article
Major performance improvements & security patches for Filament v4.12 and v5.7! image

Major performance improvements & security patches for Filament v4.12 and v5.7!

Read article
Laravel Boost Project Rules: Teach Agents Your Conventions image

Laravel Boost Project Rules: Teach Agents Your Conventions

Read article
Extract an Image's Dominant Color in Laravel image

Extract an Image's Dominant Color in Laravel

Read article