Quickstart
Write your first Joy DOM document, then render it natively on any platform.
A Joy DOM document is plain JSON. Write it once, then render it natively on the web, Apple platforms, or Android. This page writes a minimal document; pick your platform below to render it.
Write a document
Save this as hello.json. Every document has the same four top-level fields:
{
"version": 1,
"style": {
".stack": {
"display": "flex",
"flexDirection": "column",
"gap": {
"value": 12,
"unit": "px"
},
"padding": {
"value": 24,
"unit": "px"
}
},
"h1": {
"display": "flex",
"fontSize": {
"value": 32,
"unit": "px"
}
},
"p": {
"display": "flex",
"fontSize": {
"value": 16,
"unit": "px"
},
"color": "#475569"
}
},
"breakpoints": [],
"layout": {
"type": "div",
"props": {
"className": ["stack"]
},
"children": [
{
"type": "h1",
"children": ["Hello Joy DOM"]
},
{
"type": "p",
"children": ["Rendered natively from JSON."]
}
]
}
}Why does every node have `display: "flex"`?
Joy DOM requires display to be set explicitly on every node. See §4.4 Special
rules in the specification.
Render it
The same document renders on every platform. Pick yours:
React
Install @joy-dom/react and render with <JoyDom>.
Swift
Decode to Spec and render with JoyDOMView.
Kotlin
Decode with JoyDomJson and render with JoyDomCompose.
What just happened
version: 1declares the spec revision (see §2.1).styledefines shared rules keyed by selector (see §4 Styles).breakpointsis empty - responsive overrides arrive in tutorial chapter 3.layoutis the root node tree (see §3 Nodes).
Where next
Tutorial - walk through the document model, styling, breakpoints, custom components, and publishing as one connected story.
Specification - the numbered, deep-linkable contract for every supported node, property, and breakpoint condition.
Use cases - copy-paste documents for invoices, reports, forms, and resumes.