Shared data
Sharing data
The server-side adapters provide a way to preassign shared data for each request. Shared data will be automatically merged with the page props provided in your controller.
This is done through the share()
helper. It takes a dict and share this data in every request.
Page props and shared data are merged together, so be sure to namespace your shared data appropriately.
Via Middleware
On-the-fly
Use this feature sparingly as shared data is included with every response.
Flash messages (UPDATE for M4)
In order for your server-side validation errors to be available client-side, Masonite adapter shares flash errors messages automatically through an errors
prop.
It means that when you flash a message in session in your controller, the message will be available client-side (in your e.g. Vue.js component).
With the Vue adapter you would then access the messages with
If you want to update sharing flash messages logic you can override the share method in the HandleInertiaRequests
middleware.
Last updated
Was this helpful?