Skip to main content

About json-render

MyHub widgets are rendered by Vercel json-render — an open-source library that turns a declarative JSON tree into a live React UI. Everything in the widget guide ultimately compiles to a json-render schema.

Why json-render

PropertyWhat it gives you
DeclarativeWidgets are data, not code. They can be authored by humans, generated by an LLM, stored in a DB, version-controlled, diffed in PRs.
ReactiveThe renderer subscribes to the state paths each element reads. State changes re-render only the affected subtree.
ComposableElement types are pluggable. MyHub registers a library of opinionated components on top of the json-render baseline.
SandboxedA widget JSON can't execute arbitrary code — it can only call registered components and registered $computed helpers. The LLM can author widgets with no XSS attack surface.

How MyHub layers on top

The MyHub widgets-system is a thin layer over json-render that adds:

AdditionWhy
dataProvider blockA typed contract for "where does this widget's data come from", so the host can dispatch the right MCP call before render.
Plugin-namespaced $computed resolutionPlugin helpers register as <slug>_<name> so two plugins can ship a format_date without colliding.
Component baselineCard, Header, Stat, Table, etc. — the components MyHub guarantees every tenant has.
LinterCatches "spec.root references unknown id" / "child id missing" before render.

Where to read the formal grammar

For the precise semantics of every primitive ($state, $computed, watch, etc.), the source of truth is:

This guide gives you the plugin-author's view; json-render's docs give you the underlying schema, edge cases, and version history.

When to read which

You want to…Read
Build a widget for the marketplaceThis site (start at tutorials).
Understand a primitive's exact semanticsjson-render docs.
See every component MyHub shipsThe auto-generated catalog from npm run sync:widget-skills in the MyHub repo.
Write your own rendererjson-render's source.