Define JXM
Keep the view model serializable.
{
"component": "div",
"children": "JSONX"
}
Define a React view as serializable JXM, then render it as a React element, HTML string, JSX text, browser DOM output, or an Express view.
npm i jsonx react react-dom
{
"component": "section",
"props": {
"className": "notice"
},
"children": [
{ "h2": "Hello, JSONX" },
{ "p": "Defined in JSON, rendered as React." },
{
"button": {
"props": { "type": "button" },
"children": "Click me"
}
}
]
}
Defined in JSON, rendered as React.
Describe UI once, then render it where the system needs the view.
Keep the view model serializable.
{
"component": "div",
"children": "JSONX"
}
Point JSON element names at React components.
div: Box
h1: Heading
p: Text
Choose the output for the runtime.
render(jxm, map)
Return React, HTML, JSX, or Express output.
<Box>JSONX</Box>
<div class="notice">
<h2>Hello, JSONX</h2>
<p>Defined in JSON, rendered as React.</p>
</div>
Use JSONX when UI needs to move through a system as data.
Store view definitions in configuration, an API response, or a database record.
Render HTML strings or Express views from the same JXM object.
Map application components without changing the stored view shape.
Use a documented JSON shape for teams that need a durable contract.
Install the package, render a small JXM object, then move into the manual when the view model needs more structure.
> npm i jsonx react react-dom