Overview
Install and embed the @joy-dom/react renderer in a React 19 app.
@joy-dom/react renders a Joy DOM JSON document into React elements. It powers the live previews on the spec page.
Install
npm install @joy-dom/react @joy-dom/coreThe install is two packages:
@joy-dom/reactis the renderer. It listsreactandreact-dom19 as peer dependencies, so add those to your app if they are not there yet.@joy-dom/coreholds the TypeScript types and JSON Schema for the document format. It types your specs.
First render
import { } from "@joy-dom/react";
import type { } from "@joy-dom/core";
const : = {
: 1,
: {
".hello": { : "flex", : { : 16, : "px" } },
: { : "flex" },
},
: [],
: {
: "div",
: { : ["hello"] },
: [{ : "p", : ["Hello Joy DOM"] }],
},
};
export function () {
return < ={} />;
}<Joy> drops in anywhere a React component goes. It renders the document into its own shadow root, so the spec's global ids and classes stay isolated from the host page.
Where next
- Custom components render the document's kebab-case node types.
- Events and actions wire
onclick,onfocus,onblur, andonchangeto handlers. - Templates and state declare document state and read it with
$-directives. - Server rendering covers the shadow-root tradeoffs and how to load documents.
- API reference lists every prop and type.