ebess/laravel-inertia-shared-data-provider
A Laravel package for defining shared data providers for Inertia.js, letting you resolve common props once and pass them to every page without repeating code across controllers. Keeps Inertia responses consistent and easy to maintain.
HandleInertiaRequests middleware. The entire value is "shared props live in small, injectable, testable classes instead of a growing wall of closures." That is a design pattern we can adopt in a day. The package is a reference implementation, not a platform bet.HandleInertiaRequests::share() becomes a grab-bag: auth user, roles/permissions, feature flags, unread counts, cart totals, locale, flash messages. Every new global prop touches one file and one test surface, so shared props become a merge-conflict hotspot and a source of silent regressions in nav/header for every page. Provider classes make each prop independently testable — a real reduction in blast radius.Consider it when all of the following hold:
composer.json constraints against our PHP and illuminate/* versions, and against the Inertia version we run — the package predates Inertia's 1.x/v2 evolution, so closures/lazy props may work differently or not at all.Look elsewhere when:
SharedData container bound in a service provider gets us 90% of the benefit with zero risk.For executives: This is a developer-ergonomics package, not a product capability — it does not ship a user-facing feature and it does not move a roadmap date. What it does is make global page data (who is logged in, permissions, flags, counters) safer to change, which reduces the class of regression where one bad shared prop breaks headers or navigation across the whole app. Our recommendation is not to adopt the dependency: it was last released in 2021, has essentially no community usage, and is small enough that we can implement the same pattern in roughly a day and own it outright. Cost is one engineering day; risk is near zero; the alternative — taking an abandoned third-party edge into a shared code path — is the expensive option.
For engineering: Read this as a design pattern with a reference implementation, and take the pattern. Concretely: extract global props out of HandleInertiaRequests into small provider classes behind a single interface, register them in a service provider, keep the middleware as a thin aggregator, and unit-test each provider in isolation. Do it behind one narrow slice first — the auth user payload or permission list — and confirm the props still resolve correctly under config:cache, queue workers, and partial reloads. Do not add the Composer dependency: at a 1.0.0 tag from 2021 with no subsequent releases, we would be committing to maintain someone else's ~100 lines while also carrying the upgrade risk into future Laravel and Inertia majors. If we do trial the package, time-box it, pin the exact version, wrap it behind our own adapter so call sites never touch it directly, and write down the abandon criterion up front — if the abstraction is not clearly better than our own implementation by the end of the spike, we keep the code and drop the dependency.
How can I help you explore Laravel packages today?