Extensible factory
Compose reusable stages to build consistent components across your codebase.
ModularComponent composes React components through a modular factory: add capabilities stage-by-stage, keep concerns isolated, and make testing feel native.
.with() compose stages.use() generate hooks.stage() isolate for testsThe factory approach lets you add functionality as the component is built, keeping JSX focused while other stages handle state, wiring, and cross-cutting concerns.
Compose reusable stages to build consistent components across your codebase.
Separate markup, lifecycle/state, and wiring—without losing readability.
Isolate stages for tests, or turn pipelines into hooks when you don’t need rendering.
Build a pipeline of ordered stages. Each stage populates a shared argument map for downstream stages.
.use()Turn a pipeline into a hook (or isolate a single field).
.stage()Extract a stage to unit-test it with fully controlled inputs.
/registerExtensions offer a register entrypoint for automatic stage registration.
Start with the core factory, add the default stage pack, and add on your custom stages as your app needs.
Core and the recommended default capability pack.
npm install @modular-component/core @modular-component/defaultKeep component definitions clean with stage registration.
import '@modular-component/default/register'Compose stages with a readable chain and keep JSX at the edge.
const MyComponent = ModularComponent<{ label: string }>()
.withDefaultProps({ label: 'Hello' })
.withLifecycle(({ props }) => ({
upper: props.label.toUpperCase()
}))
.withRender(({ lifecycle }) => (
<h2>{lifecycle.upper}</h2>
))