defineComponent
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
The component name. Used in error messages, the registry, and slot validation. Must be unique.
Schema defining the component’s accepted props. Each key is a prop name, each value is a prop descriptor.
Receives the resolved props (defaults applied, validated) and returns a vnode.
Prop descriptor
Each entry inprops accepts the following fields:
| Field | Type | Description |
|---|---|---|
type | string | One of string, number, boolean, function, object, array, any, slot |
required | boolean | Throws if the prop is missing or null |
default | any | Value used when the prop is not passed |
enum | array | Restricts the value to a list of allowed strings |
accepts | string | For slot type only — restricts to a specific component name |
Prop types
Contract errors
If a prop contract is violated, Solar throws a structuredContractError immediately — before the component renders:
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: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:
_source property set to the component name — used by the slot system for type checking.