@json-render/vue
Vue 3 components, providers, and composables.
Providers
StateProvider
| Prop | Type | Description |
|---|---|---|
store | StateStore | External store (controlled mode). When provided, initialState and onStateChange are ignored. |
initialState | Record<string, unknown> | Initial state model (uncontrolled mode). |
onStateChange | (changes: Array<{ path: string; value: unknown }>) => void | Callback when state changes (uncontrolled mode). Called once per set or update with all changed entries. |
External Store (Controlled Mode)
Pass a StateStore to bypass the internal state and wire json-render to any state management library:
ActionProvider
VisibilityProvider
VisibilityProvider reads state from the parent StateProvider automatically. Conditions in specs use the VisibilityCondition format with $state paths (e.g. { "$state": "/path" }, { "$state": "/path", "eq": value }). See visibility for the full syntax.
ValidationProvider
defineRegistry
Create a type-safe component registry from a catalog. Components receive props, children, slots, emit, on, and loading with catalog-inferred types.
When the catalog declares actions, the actions field is required. When the catalog has no actions (e.g. actions: {}), the field is optional. When passing stubs, any async () => {} is sufficient.
Components
Renderer
Component Props (via defineRegistry)
Use children for the default slot. For other slots declared by the catalog, add a top-level slots map to the spec element:
The component renders these regions with Vue's native slot functions: slots.header?.(), slots.footer?.(), and so on. slots.default?.() renders the spec's children; children is a convenience alias for that rendered result. In the JSON spec, keep default content in children rather than adding a default entry to slots.
Use emit("press") for simple event firing. Use on("click") when you need metadata like shouldPreventDefault:
BaseComponentProps
Catalog-agnostic base type for building reusable component libraries that are not tied to a specific catalog:
Composables
useStateStore
Note:
stateis aShallowRef<StateModel>, not a plain object. Usestate.valueto read the current state. This differs from the React renderer.
useStateValue
Returns a ComputedRef that automatically updates when the state at path changes. Use .value to access the current value.
useStateBinding (deprecated)
Deprecated. Use
$bindStateexpressions withbindingsprop instead.
useActions
useAction
useIsVisible
useFieldValidation
ValidationConfig is { checks?: ValidationCheck[], validateOn?: 'change' | 'blur' | 'submit' }.
Differences from @json-render/react
| API | React | Vue | Note |
|---|---|---|---|
useStateStore().state | StateModel (plain object) | ShallowRef<StateModel> | Vue reactivity; use state.value |
useStateValue() | T | undefined | ComputedRef<T | undefined> | Vue reactivity; use .value |
useStateBinding() | [T | undefined, setter] | [ComputedRef<T | undefined>, setter] | Vue reactivity; use value.value |
useAction().isLoading | boolean | ComputedRef<boolean> | Vue reactivity; use .value |
useFieldValidation().state | FieldValidationState | ComputedRef<FieldValidationState> | Vue reactivity; use .value |
useFieldValidation().errors | string[] | ComputedRef<string[]> | Vue reactivity; use .value |
useFieldValidation().isValid | boolean | ComputedRef<boolean> | Vue reactivity; use .value |
VisibilityContextValue.ctx | CoreVisibilityContext | ComputedRef<CoreVisibilityContext> | Vue reactivity; use ctx.value |
children type | React.ReactNode | VNode | VNode[] | Platform-specific |
useBoundProp | exported | exported | Same API; returns [value, setValue] |
VisibilityProviderProps | exported | not exported (no props) | Vue uses slot, no prop needed |
| Streaming hooks | useUIStream, useChatUI | useUIStream, useChatUI | Same API; returns Vue Ref values |