coordinate-components

Share state between Blazor components using cascading values and scoped services.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill coordinate-components-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: coordinate-components
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/coordinate-components
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill coordinate-components-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Blazor components often need to share state without a direct parent-child parameter relationship, and standard cascading values fail to reach interactive children across render mode boundaries. This Skill guides you through choosing and implementing the right state-sharing mechanism for your Blazor app. ## Core Features & Use Cases - CascadingValue for subtree state: Flow data like themes or layout config to all descendants within the same render mode without prop drilling. - CascadingValueSource<T> via DI: Share app-wide state such as current user or feature flags across all render modes, with NotifyChangedAsync to update subscribers without page reloads. - Scoped services with change events: Manage mutable shared state like shopping carts or notification counts with an Action event pattern and proper disposal. - Use Case: You need a shopping cart count visible in both the header and product pages of a Blazor Server app. Register a scoped CartState service, subscribe to its OnChange event in each component, and every update re-renders all subscribers automatically. ## Quick Start Ask the AI to set up a shared shopping cart state accessible from multiple Blazor components using a scoped service with change notifications.

Frequently Asked Questions about coordinate-components

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I share state between Blazor components without parameters?

Use a scoped service with an Action change event for mutable shared state like carts or notification counts, or CascadingValueSource<T> registered in DI for app-wide values. Both avoid passing parameters through every intermediate component.

Why is my CascadingValue not reaching interactive Blazor components?

A CascadingValue in a static SSR layout cannot cross render mode boundaries, so interactive children receive null. Register a CascadingValueSource<T> in DI or use a scoped service instead, since DI services resolve per-circuit rather than from the component tree.

Should I use scoped or singleton services for state in Blazor Server?

Use scoped services for per-user state on Blazor Server because singletons are shared across all circuits and leak one user's data to others. On WebAssembly, singletons are per-tab and safe, but code targeting both hosting models should use scoped.

How do I update a cascading value in Blazor without reloading the page?

Inject CascadingValueSource<T> and call NotifyChangedAsync with the new value to push updates to all CascadingParameter subscribers. Never use NavigationManager.Refresh with forceReload, which destroys the circuit and forces a full page reload.

Why does StateHasChanged throw an exception from a timer or background task?

StateHasChanged called outside the Blazor synchronization context throws an InvalidOperationException because the thread is not associated with the Dispatcher. Wrap the call in InvokeAsync and store the handler delegate so you can unsubscribe it in Dispose.