<juo-context-root> custom element.
Providing a context
CallprovideContext() once at startup, before blocks render:
Consuming a context
In a vanilla renderer, useinjectContext() for a one-shot synchronous read against the surrounding DOM:
useContext composable / hook that wires signals into native reactivity — see the Vue, React, and Preact guides.
Reactive updates
If the provided value can change over time, usesubscribeContext:
useContext already bridges signal updates into the host framework’s reactivity. See Reactivity.
Scoping and overrides
Every<juo-context-root> element captures context-provide and context-request events at its own boundary — providers are stored on the root that catches the event, and requests are answered by the nearest root above the requester. That makes contexts naturally scoped.
Any context can be overridden for a sub-tree by nesting a second <juo-context-root> and providing a different value on it. Contexts that the inner root does not re-provide fall through to the outer scope.
- Previews and Storybook. Wrap a block in a nested root that provides mock services.
- Workflow overlays. The flow overlay creates its own root so it can swap in a flow-specific
WorkflowServiceandPageContextwithout disturbing the rest of the page. - Tenant or surface scoping. Different sections of the page can run against different adapters.
Defining a custom context
@juo/blocks ships context keys for every built-in service — SubscriptionServiceContext, CustomerServiceContext, and so on. Define a custom context with createContext when sharing something beyond the built-in services.