Published on October 29, 2020

This release adds the ability to define "lazy props". (#175))

Lazy props are data that's not included on the initial visit to a page. These properties only get included on partial reloads, using the only option. This is useful for "expensive" data, such as requests to 3rd party APIs, that are not needed on the initial visit to a page.

You can mark a prop as lazy using the new Inertia::lazy() method:

return Inertia::render('Users/Index', [
    'users' => User::paginate('id', 'name', 'email'),
    'companies' => Inertia::lazy(fn () => Company::get('id', 'name')),

Then, to load this prop later on, you perform a partial reload from your page component, either using a link:

<inertia-link class="hover:underline" href="/users" :only="['companies']">Load companies</inertia-link>

Or by doing this programatically:

Inertia.reload({ only: ['companies'] })