Shared data
Global share
Section titled “Global share”Lives for the life of the process (or until cleared):
Inertia.share("appName", "Kona")Inertia.share(mapOf("features" to listOf("a", "b")))Inertia.share("appName", "Kona");Inertia.share(Map.of("features", List.of("a", "b")));Inspect with Inertia.manager().shared(). Clear with manager.clearShared().
Per-request share
Section titled “Per-request share”Subclass middleware:
class HandleInertia : HandleInertiaRequests() { override fun share(request: Request) = mapOf( "path" to request.path, "auth" to mapOf("user" to currentUser(request)), )}public class HandleInertia extends HandleInertiaRequests { @Override public Map<String, Object> share(Request request) { return Map.of("path", request.getPath()); }}Internally this calls manager.shareForRequest(props) for the duration of the request. The ThreadLocal map is cleared when the middleware finishes.
Merge order
Section titled “Merge order”- Global
share - Middleware /
shareForRequest - Props passed to
Inertia.render(highest priority)
Duplicate keys: later layers win. Prefer putting stable app metadata in global share and request-specific flash/auth in middleware so controllers stay thin.
Flash-style patterns
Section titled “Flash-style patterns”There is no separate “flash” bag in kona-inertia. Typical approach:
- Store flash in the session from a controller or filter.
- In
share(request), read and clear that session key into props (e.g."flash" to mapOf("success" to …)). - Display on the client from
usePage().props.flash(Vue/React adapter APIs — see inertiajs.com).
Testing shared props
Section titled “Testing shared props”In unit tests, boot a manager, call share / shareForRequest, render with an explicit Request, and assert the JSON props map. See Testing.