Shared data
Share props with every page, statically or per request, and control the shared prop key list.
Shared props are merged into every page. A page prop with the same key wins.
Register shared values
Share values from anywhere with an HttpContext, such as middleware or a handler:
The value can be any prop, including another factory:
plans is resolved once and kept by the client across visits.
The shared prop key list
The top-level shared keys are listed in the page object so the client can keep them across navigations:
errors is always shared, so the list always contains at least "errors". Turn the list off with:
When to use shared props
Use shared props for values that every page needs and that are cheap to compute:
- the signed-in user or tenant name
- the application name and locale
- feature flags
- a once-per-client value such as a plan catalogue
Keep large or page-specific data in page props. Shared props are considered on every page response, including partial reloads, so keep them cheap or wrap an expensive value in Once.
Share once
Wrapping a shared value in Once is the equivalent of Laravel's shareOnce. The client keeps the value across visits and sends X-Inertia-Except-Once-Props; the loader does not run again until the value expires.
TypeScript
The generated declarations infer shared props from the values passed to o.Share(...). Factories and per-request shares are typed as unknown; use o.TypeScript.SharedProps<T>() when you want an explicit shape. See TypeScript types.