The PR introduces an ability to persist properties on partial requests.
When making a partial reload, Inertia will only evaluate and include on the response properties, specified in the only array. This adds some extra inconvenience when you need to carry some common data between pages (e.g. current user data).
Inertia::persist('auth.user');
// or
inertia()->persist(['auth.user'])
router.visit(url, {
only: ['billing'],
})
$props = [
// Included on partial reload
'auth' => [
'user' => new LazyProp(function () {
return [
'name' => 'Jonathan Reinink',
'email' => 'jonathan@example.com',
];
}),
],
// Included on partial reload
'billing' => [
//
],
// Not included on partial reload
'data' => [
//
],
];
Alternatively, you can define persistent properties globally in a middleware. These will be available on any request.
The PR introduces an ability to persist properties on partial requests.
When making a partial reload, Inertia will only evaluate and include on the response properties, specified in the
only
array. This adds some extra inconvenience when you need to carry some common data between pages (e.g. current user data).Alternatively, you can define persistent properties globally in a middleware. These will be available on any request.
Example use cases: