Joy DOM

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 you see on the spec page.

Install

bun add @joy-dom/react @joy-dom/spec

@joy-dom/react declares react and react-dom 19 as peer dependencies; install them in your app if they aren't already there. @joy-dom/spec carries the TypeScript types and JSON Schema for the document format — install it alongside so you can type your specs.

First render

import {  } from "@joy-dom/react";
import type { Spec } from "@joy-dom/spec";

const : Spec = {
  : 1,
  : {
    ".hello": { : "flex", : { : 16, : "px" } },
    : { : "flex" },
  },
  : [],
  : {
    : "div",
    : { : ["hello"] },
    : [{ : "p", : ["Hello Joy DOM"] }],
  },
};

export function () {
  return < ={} />;
}

Drop <JoyDom> anywhere you'd put a regular React component. 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

On this page