You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After the client has received this prop, subsequent requests will skip resolving the callback entirely and the prop will be excluded from the response. The client will automatically reuse the remembered value.
18
18
19
19
Navigating to a page without the once prop will break the chain, and the prop will be resolved again on the next page that has it.
20
20
21
-
## Sharing Once Props
22
-
23
-
You may share once props globally using the `Inertia::share()` method.
You may also define a dedicated `shareOnce()` method in your middleware.
88
+
89
+
```php
90
+
class HandleInertiaRequests extends Middleware
91
+
{
92
+
public function shareOnce(Request $request): array
93
+
{
94
+
return [
95
+
'countries' => fn () => Country::all(),
96
+
];
97
+
}
98
+
}
99
+
```
100
+
95
101
## Prefetching
96
102
97
103
Once props work with [prefetching](/v2/data-props/prefetching). The client automatically includes any remembered once props in prefetched responses, so navigating to a prefetched page will already have the once props available.
@@ -104,7 +110,7 @@ The `once()` modifier may be chained onto [deferred](/v2/data-props/deferred-pro
0 commit comments