Skip to content

Hook or Provider?

Both entry points return the same BroadcastActions. The difference is where the channel is opened and who can reach it.

Situation Use
One component (or a few unrelated ones) each need their own channel useBroadcastChannel
Many components in a subtree share one channel BroadcastProvider
Several independent channels in one component useBroadcastChannel, once per channel
A design-system-level “app bus” BroadcastProvider near the root

Ask: if I add a second consumer, would I copy-paste the same hook call? If yes, lift the channel into a provider and let consumers call useBroadcastProvider().

Mixing is fine: a provider can carry the shared app channel while an isolated widget opens its own widget-settings channel with the hook.