Skip to main content
The core primitive in Solar. Every component is defined through a schema that declares its shape explicitly. Props are typed and validated at runtime before the component renders.

Config

string
required
The component name. Used in error messages, the registry, and slot validation. Must be unique.
object
Schema defining the component’s accepted props. Each key is a prop name, each value is a prop descriptor.
function
required
Receives the resolved props (defaults applied, validated) and returns a vnode.

Prop descriptor

Each entry in props accepts the following fields:

Prop types

Contract errors

If a prop contract is violated, Solar throws a structured ContractError before the component renders:
Use e.toJSON() to get the structured object, or e.message for the human-readable string.

Slots

Slots are typed component composition. A slot prop expects a vnode produced by a specific component:
Passing a plain createElement vnode instead of a Button vnode throws a ContractError.

Return value

defineComponent returns a component function. Call it with props to get a vnode:
The returned vnode has a _source property set to the component name. The slot system uses it for type checking.