@json-render/svelte
Svelte 5 components, providers, and helpers for rendering json-render specs.
Installation
npm install @json-render/core @json-render/sveltePeer dependencies: svelte ^5.0.0 and zod ^4.0.0.
npm install svelte zodComponents
Renderer
Renders a spec with your component registry. If spec is null, it renders nothing.
JsonUIProvider
Convenience wrapper around StateProvider, VisibilityProvider, ValidationProvider, and ActionProvider.
defineRegistry
Create a typed component registry and action handlers from a catalog.
handlers is designed for JsonUIProvider/ActionProvider. executeAction is an imperative helper.
Component Props
Registry components receive BaseComponentProps<TProps>:
Use emit("eventName") to trigger handlers declared in the spec on bindings.
Context Helpers
Use these helpers inside Svelte components:
getStateValue(path)- read/write state via.currentgetBoundProp(() => value, () => bindingPath)- write back resolved$bindState/$bindItemvaluesisVisible(condition)- evaluate visibility via.currentgetAction(name)- read a registered action handler via.currentgetFieldValidation(ctx, path, config)- get field validation state + actions
For advanced usage, access full contexts:
getStateContext()getActionContext()getVisibilityContext()getValidationContext()getOptionalValidationContext()
Streaming
createUIStream
createChatUI
Schema Export
Use schema from @json-render/svelte when defining catalogs for Svelte specs.