Provide and inject
Share typed services through a component subtree without prop drilling.
On this page
Use props for local parent/child data. Use Scope to provide a service or reactive value to descendants that need it across several component boundaries.
#[derive(Clone)]
struct ThemeAccent(inrux::Color);
let scope = inrux::Scope::default()
.provide(ThemeAccent(inrux::Color(29, 112, 98)));
Pass that Scope when mounting the application. A descendant reads the nearest matching type:
let accent = scope.inject::<ThemeAccent>();
inject returns Option<Arc<ThemeAccent>>. Handle the missing case. A nested provider of the same type shadows the outer value for its subtree.
Provide inside a view
<Provide value={ThemeAccent(Color(29, 112, 98))}>
<Summary />
</Provide>
Import Summary explicitly and define ThemeAccent in an accessible Rust module. Provide does not register a component globally.
Plain provided values are immutable. Provide a Signal or owned reactive service when updates should trigger tracked reads. Cloning a Signal shares its value; creating another Signal creates independent state.
Keep dependencies visible
Document required injected services in a component's API. Prefer a typed wrapper when two values have the same underlying type but different meanings. Avoid using Scope as an untyped global store.
A dedicated Pinia-like store and routing package are not part of the alpha. You can still share ordinary Rust services and reactive handles through Scope.