Skip to content
Back to search

json-render

The Generative UI framework

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/vercel-labs/json-render with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/vercel-labs/json-render'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/vercel-labs--json-render/badge.svg)](/listings/vercel-labs--json-render)

HTML

<a href="/listings/vercel-labs--json-render"><img src="/api/listings/vercel-labs--json-render/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

1. Define Your Catalog

import { defineCatalog } from "@json-render/core";
import { schema } from "@json-render/react/schema";
import { z } from "zod";

const catalog = defineCatalog(schema, {
  components: {
    Card: {
      props: z.object({ title: z.string() }),
      description: "A card container",
    },
    Metric: {
      props: z.object({
        label: z.string(),
        value: z.string(),
        format: z.enum(["currency", "percent", "number"]).nullable(),
      }),
      description: "Display a metric value",
    },
    Button: {
      props: z.object({
        label: z.string(),
        action: z.string(),
      }),
      description: "Clickable button",
    },
  },
  actions: {
    export_report: { description: "Export dashboard to PDF" },
    refresh_data: { description: "Refresh all metrics" },
  },
});

2. Define Your Components

import { defineRegistry, Renderer } from "@json-render/react";

const { registry } = defineRegistry(catalog, {
  components: {
    Card: ({ props, children }) => (
      <div className="card">
        <h3>{props.title}</h3>
        {children}
      </div>
    ),
    Metric: ({ props }) => (
      <div className="metric">
        <span>{props.label}</span>
        <span>{format(props.value, props.format)}</span>
      </div>
    ),
    Button: ({ props, emit }) => (
      <button onClick={() => emit("press")}>{props.label}</button>
    ),
  },
});

3. Render AI-Generated Specs

function Dashboard({ spec }) {
  return <Renderer spec={spec} registry={registry} />;
}

**That's it.** AI generates JSON, you render it safely.

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 873 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # json-render
  2. **The Generative UI framework.**
  3. Generate dynamic, personalized UIs from prompts without sacrificing reliability. Predefined components and actions for safe, predictable output.
  4. <p>
  5. <a href="https://vercel.com/labs#labs-products"><img alt="Vercel Labs Product" src="https://img.shields.io/badge/LABS-PRODUCT-0a0a0a.svg?style=for-the-badge&amp;logo=Vercel&amp;labelColor=000000" height="28"></a>
  6. <a href="https://www.npmjs.com/package/@json-render/core"><img alt="npm version: @json-render/core" src="https://img.shields.io/npm/v/%40json-render%2Fcore.svg?style=for-the-badge&amp;labelColor=000000" height="28"></a>
  7. <a href="https://github.com/vercel-labs/json-render/blob/main/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/github/license/vercel-labs/json-render.svg?style=for-the-badge&amp;labelColor=000000" height="28"></a>
  8. <a href="https://www.npmjs.com/package/@json-render/core"><img alt="npm downloads per month: @json-render/core" src="https://img.shields.io/npm/dm/%40json-render%2Fcore.svg?style=for-the-badge&amp;labelColor=000000&amp;label=npm%20downloads" height="28"></a>
  9. </p>
  10. ```bash
  11. # for React
  12. npm install @json-render/core @json-render/react
  13. # for React with pre-built shadcn/ui components
  14. npm install @json-render/shadcn
  15. # or for React Native
  16. npm install @json-render/core @json-render/react-native
  17. # or for video
  18. npm install @json-render/core @json-render/remotion
  19. # or for PDF documents
  20. npm install @json-render/core @json-render/react-pdf
  21. # or for HTML email
  22. npm install @json-render/core @json-render/react-email @react-email/components @react-email/render
  23. # or for Vue
  24. npm install @json-render/core @json-render/vue
  25. # or for Svelte
  26. npm install @json-render/core @json-render/svelte
  27. # or for SolidJS
  28. npm install @json-render/core @json-render/solid
  29. # or for terminal UIs
  30. npm install @json-render/core @json-render/ink ink react
  31. # or for full Next.js apps (routes, layouts, SSR, metadata)
  32. npm install @json-render/core @json-render/react @json-render/next
  33. # or for 3D scenes (and gaussian splatting via the GaussianSplat component)
  34. npm install @json-render/core @json-render/react-three-fiber @react-three/fiber @react-three/drei three
  35. ```
  36. ## Why json-render?
  37. json-render is a **Generative UI** framework: AI generates interfaces from natural language prompts, constrained to components you define. You set the guardrails, AI generates within them:
  38. - **Guardrailed** - AI can only use components in your catalog
  39. - **Predictable** - JSON output matches your schema, every time
  40. - **Fast** - Stream and render progressively as the model responds
  41. - **Cross-Platform** - React, Vue, Svelte, Solid (web), React Native (mobile) from the same catalog
  42. - **Batteries Included** - 36 pre-built shadcn/ui components ready to use
  43. ## Quick Start
  44. ### 1. Define Your Catalog
  45. ```typescript
  46. import { defineCatalog } from "@json-render/core";
  47. import { schema } from "@json-render/react/schema";
  48. import { z } from "zod";
  49. const catalog = defineCatalog(schema, {
  50. components: {
  51. Card: {
  52. props: z.object({ title: z.string() }),
  53. description: "A card container",
  54. },
  55. Metric: {
  56. props: z.object({
  57. label: z.string(),
  58. value: z.string(),
  59. format: z.enum(["currency", "percent", "number"]).nullable(),
  60. }),
  61. description: "Display a metric value",
  62. },
  63. Button: {
  64. props: z.object({
  65. label: z.string(),
  66. action: z.string(),
  67. }),
  68. description: "Clickable button",
  69. },
  70. },
  71. actions: {
  72. export_report: { description: "Export dashboard to PDF" },
  73. refresh_data: { description: "Refresh all metrics" },
  74. },
  75. });
  76. ```
  77. ### 2. Define Your Components
  78. ```tsx
  79. import { defineRegistry, Renderer } from "@json-render/react";
  80. const { registry } = defineRegistry(catalog, {
  81. components: {
  82. Card: ({ props, children }) => (
  83. <div className="card">
  84. <h3>{props.title}</h3>
  85. {children}
  86. </div>
  87. ),
  88. Metric: ({ props }) => (
  89. <div className="metric">
  90. <span>{props.label}</span>
  91. <span>{format(props.value, props.format)}</span>
  92. </div>
  93. ),
  94. Button: ({ props, emit }) => (
  95. <button onClick={() => emit("press")}>{props.label}</button>
  96. ),
  97. },
  98. });
  99. ```
  100. ### 3. Render AI-Generated Specs
  101. ```tsx
  102. function Dashboard({ spec }) {
  103. return <Renderer spec={spec} registry={registry} />;
  104. }
  105. ```
  106. **That's it.** AI generates JSON, you render it safely.
  107. ---
  108. ## Packages
  109. | Package | Description |
  110. | --------------------------- | ---------------------------------------------------------------------- |
  111. | `@json-render/core` | Schemas, catalogs, AI prompts, dynamic props, SpecStream utilities |
  112. | `@json-render/react` | React renderer, contexts, hooks |
  113. | `@json-render/vue` | Vue 3 renderer, composables, providers |
  114. | `@json-render/svelte` | Svelte 5 renderer with runes-based reactivity |
  115. | `@json-render/solid` | SolidJS renderer with fine-grained reactive contexts |
  116. | `@json-render/shadcn` | 36 pre-built shadcn/ui components (Radix UI + Tailwind CSS) |
  117. | `@json-render/shadcn-svelte`| 36 pre-built shadcn-svelte components (Svelte 5 + Tailwind CSS) |
  118. | `@json-render/react-three-fiber` | React Three Fiber renderer for 3D scenes (20 built-in components, including GaussianSplat) |
  119. | `@json-render/react-native` | React Native renderer with standard mobile components |
  120. | `@json-render/next` | Next.js renderer — JSON becomes full apps with routes, layouts, SSR |
  121. | `@json-render/tanstack-start` | TanStack Start renderer — full apps with routes, layouts, SSR, and head metadata |
  122. | `@json-render/remotion` | Remotion video renderer, timeline schema |
  123. | `@json-render/react-pdf` | React PDF renderer for generating PDF documents from specs |
  124. | `@json-render/react-email` | React Email renderer for HTML/plain-text emails from specs |
  125. | `@json-render/chat` | Chat SDK renderer for native Slack, Teams, and Discord cards from specs |
  126. | `@json-render/ink` | Ink terminal renderer with built-in components for interactive TUIs. |
  127. | `@json-render/image` | Image renderer for SVG/PNG output (OG images, social cards) via Satori |
  128. | `@json-render/directives` | Pre-built custom directives — $format, $math, $concat, $count, $truncate, $pluralize, $join, $t (i18n) |
  129. | `@json-render/codegen` | Utilities for generating code from json-render UI trees |
  130. | `@json-render/devtools` | Framework-agnostic devtools core — panel UI, event store, picker, stream taps |
  131. | `@json-render/devtools-react` | React adapter for `@json-render/devtools` (drop-in `<JsonRenderDevtools />`) |
  132. | `@json-render/devtools-vue` | Vue adapter for `@json-render/devtools` |
  133. | `@json-render/devtools-svelte` | Svelte adapter for `@json-render/devtools` |
  134. | `@json-render/devtools-solid` | SolidJS adapter for `@json-render/devtools` |
  135. | `@json-render/redux` | Redux / Redux Toolkit adapter for `StateStore` |
  136. | `@json-render/zustand` | Zustand adapter for `StateStore` |
  137. | `@json-render/jotai` | Jotai adapter for `StateStore` |
  138. | `@json-render/xstate` | XState Store (atom) adapter for `StateStore` |
  139. | `@json-render/mcp` | MCP Apps integration for Claude, ChatGPT, Cursor, VS Code |
  140. | `@json-render/yaml` | YAML wire format with streaming parser, edit modes, AI SDK transform |
  141. ## Renderers
  142. ### React (UI)
  143. ```tsx
  144. import { defineRegistry, Renderer } from "@json-render/react";
  145. import { schema } from "@json-render/react/schema";
  146. // Flat spec format (root key + elements map)
  147. const spec = {
  148. root: "card-1",
  149. elements: {
  150. "card-1": {
  151. type: "Card",
  152. props: { title: "Hello" },
  153. children: ["button-1"],
  154. },
  155. "button-1": {
  156. type: "Button",
  157. props: { label: "Click me" },
  158. children: [],
  159. },
  160. },
  161. };
  162. // defineRegistry creates a type-safe component registry
  163. const { registry } = defineRegistry(catalog, { components });
  164. <Renderer spec={spec} registry={registry} />;
  165. ```
  166. ### Vue (UI)
  167. ```typescript
  168. import { h } from "vue";
  169. import { defineRegistry, Renderer } from "@json-render/vue";
  170. import { schema } from "@json-render/vue/schema";
  171. const { registry } = defineRegistry(catalog, {
  172. components: {
  173. Card: ({ props, children }) =>
  174. h("div", { class: "card" }, [h("h3", null, props.title), children]),
  175. Button: ({ props, emit }) =>
  176. h("button", { onClick: () => emit("press") }, props.label),
  177. },
  178. });
  179. // In your Vue component template:
  180. // <Renderer :spec="spec" :registry="registry" />
  181. ```
  182. ### Svelte (UI)
  183. ```typescript
  184. import { defineRegistry, Renderer } from "@json-render/svelte";
  185. import { schema } from "@json-render/svelte/schema";
  186. const { registry } = defineRegistry(catalog, {
  187. components: {
  188. Card: ({ props, children }) => /* Svelte 5 snippet */,
  189. Button: ({ props, emit }) => /* Svelte 5 snippet */,
  190. },
  191. });
  192. // In your Svelte component:
  193. // <Renderer spec={spec} registry={registry} />
  194. ```
  195. ### Solid (UI)
  196. ```tsx
  197. import { defineRegistry, JSONUIProvider, Renderer } from "@json-render/solid";
  198. import { schema } from "@json-render/solid/schema";
  199. const { registry } = defineRegistry(catalog, {
  200. components: {
  201. Card: (renderProps) => <div>{renderProps.children}</div>,
  202. Button: (renderProps) => (
  203. <button onClick={() => renderProps.emit("press")}>
  204. {renderProps.props.label}
  205. </button>
  206. ),
  207. },
  208. });
  209. <JSONUIProvider registry={registry}>
  210. <Renderer spec={spec} registry={registry} />
  211. </JSONUIProvider>;
  212. ```
  213. ### shadcn/ui (Web)
  214. ```tsx
  215. import { defineCatalog } from "@json-render/core";
  216. import { schema } from "@json-render/react/schema";
  217. import { defineRegistry, Renderer } from "@json-render/react";
  218. import { shadcnComponentDefinitions } from "@json-render/shadcn/catalog";
  219. import { shadcnComponents } from "@json-render/shadcn";
  220. // Pick components from the 36 standard definitions
  221. const catalog = defineCatalog(schema, {
  222. components: {
  223. Card: shadcnComponentDefinitions.Card,
  224. Stack: shadcnComponentDefinitions.Stack,
  225. Heading: shadcnComponentDefinitions.Heading,
  226. Button: shadcnComponentDefinitions.Button,
  227. },
  228. actions: {},
  229. });
  230. // Use matching implementations
  231. const { registry } = defineRegistry(catalog, {
  232. components: {
  233. Card: shadcnComponents.Card,
  234. Stack: shadcnComponents.Stack,
  235. Heading: shadcnComponents.Heading,
  236. Button: shadcnComponents.Button,
  237. },
  238. });
  239. <Renderer spec={spec} registry={registry} />;
  240. ```
  241. ### React Native (Mobile)
  242. ```tsx
  243. import { defineCatalog } from "@json-render/core";
  244. import { schema } from "@json-render/react-native/schema";
  245. import {
  246. standardComponentDefinitions,
  247. standardActionDefinitions,
  248. } from "@json-render/react-native/catalog";
  249. import { defineRegistry, Renderer } from "@json-render/react-native";
  250. // 25+ standard components included
  251. const catalog = defineCatalog(schema, {
  252. components: { ...standardComponentDefinitions },
  253. actions: standardActionDefinitions,
  254. });
  255. const { registry } = defineRegistry(catalog, { components: {} });
  256. <Renderer spec={spec} registry={registry} />;
  257. ```
  258. ### Remotion (Video)
  259. ```tsx
  260. import { Player } from "@remotion/player";
  261. import {
  262. Renderer,
  263. schema,
  264. standardComponentDefinitions,
  265. } from "@json-render/remotion";
  266. // Timeline spec format
  267. const spec = {
  268. composition: {
  269. id: "video",
  270. fps: 30,
  271. width: 1920,
  272. height: 1080,
  273. durationInFrames: 300,
  274. },
  275. tracks: [{ id: "main", name: "Main", type: "video", enabled: true }],
  276. clips: [
  277. {
  278. id: "clip-1",
  279. trackId: "main",
  280. component: "TitleCard",
  281. props: { title: "Hello" },
  282. from: 0,
  283. durationInFrames: 90,
  284. },
  285. ],
  286. audio: { tracks: [] },
  287. };
  288. <Player
  289. component={Renderer}
  290. inputProps={{ spec }}
  291. durationInFrames={spec.composition.durationInFrames}
  292. fps={spec.composition.fps}
  293. compositionWidth={spec.composition.width}
  294. compositionHeight={spec.composition.height}
  295. />;
  296. ```
  297. ### React PDF (Documents)
  298. ```typescript
  299. import { renderToBuffer } from "@json-render/react-pdf";
  300. const spec = {
  301. root: "doc",
  302. elements: {
  303. doc: {
  304. type: "Document",
  305. props: { title: "Invoice" },
  306. children: ["page-1"],
  307. },
  308. "page-1": {
  309. type: "Page",
  310. props: { size: "A4" },
  311. children: ["heading-1", "table-1"],
  312. },
  313. "heading-1": {
  314. type: "Heading",
  315. props: { text: "Invoice #1234", level: "h1" },
  316. children: [],
  317. },
  318. "table-1": {
  319. type: "Table",
  320. props: {
  321. columns: [
  322. { header: "Item", width: "60%" },
  323. { header: "Price", width: "40%", align: "right" },
  324. ],
  325. rows: [
  326. ["Widget A", "$10.00"],
  327. ["Widget B", "$25.00"],
  328. ],
  329. },
  330. children: [],
  331. },
  332. },
  333. };
  334. // Render to buffer, stream, or file
  335. const buffer = await renderToBuffer(spec);
  336. ```
  337. ### React Email (Email)
  338. ```typescript
  339. import { renderToHtml } from "@json-render/react-email";
  340. import { schema, standardComponentDefinitions } from "@json-render/react-email";
  341. import { defineCatalog } from "@json-render/core";
  342. const catalog = defineCatalog(schema, {
  343. components: standardComponentDefinitions,
  344. });
  345. const spec = {
  346. root: "html-1",
  347. elements: {
  348. "html-1": {
  349. type: "Html",
  350. props: { lang: "en", dir: "ltr" },
  351. children: ["head-1", "body-1"],
  352. },
  353. "head-1": { type: "Head", props: {}, children: [] },
  354. "body-1": {
  355. type: "Body",
  356. props: { style: { backgroundColor: "#f6f9fc" } },
  357. children: ["container-1"],
  358. },
  359. "container-1": {
  360. type: "Container",
  361. props: {
  362. style: { maxWidth: "600px", margin: "0 auto", padding: "20px" },
  363. },
  364. children: ["heading-1", "text-1"],
  365. },
  366. "heading-1": { type: "Heading", props: { text: "Welcome" }, children: [] },
  367. "text-1": {
  368. type: "Text",
  369. props: { text: "Thanks for signing up." },
  370. children: [],
  371. },
  372. },
  373. };
  374. const html = await renderToHtml(spec);
  375. ```
  376. ### Chat SDK (Slack, Teams, Discord)
  377. ```typescript
  378. import { defineCatalog } from "@json-render/core";
  379. import {
  380. schema,
  381. standardComponentDefinitions,
  382. streamCard,
  383. toCard,
  384. } from "@json-render/chat";
  385. import { streamText } from "ai";
  386. const catalog = defineCatalog(schema, {
  387. components: standardComponentDefinitions,
  388. });
  389. // Stream a generated card into a Chat SDK thread
  390. chat.onNewMention(async (thread, message) => {
  391. const result = streamText({
  392. model: "anthropic/claude-haiku-4.5",
  393. system: catalog.prompt(),
  394. prompt: message.text,
  395. });
  396. await streamCard(thread, result.textStream);
  397. });
  398. // Or convert a complete spec and post it
  399. await thread.post(toCard(spec, { limits: { tables: 1, charts: 2 } }));
  400. ```
  401. ### Image (SVG/PNG)
  402. ```typescript
  403. import { renderToPng } from "@json-render/image/render";
  404. const spec = {
  405. root: "frame",
  406. elements: {
  407. frame: {
  408. type: "Frame",
  409. props: { width: 1200, height: 630, backgroundColor: "#1a1a2e" },
  410. children: ["heading"],
  411. },
  412. heading: {
  413. type: "Heading",
  414. props: { text: "Hello World", level: "h1", color: "#ffffff" },
  415. children: [],
  416. },
  417. },
  418. };
  419. // Render to PNG (requires @resvg/resvg-js)
  420. const png = await renderToPng(spec, { fonts });
  421. // Or render to SVG string
  422. import { renderToSvg } from "@json-render/image/render";
  423. const svg = await renderToSvg(spec, { fonts });
  424. ```
  425. ### Three.js (3D)
  426. ```tsx
  427. import { defineCatalog } from "@json-render/core";
  428. import { schema, defineRegistry } from "@json-render/react";
  429. import {
  430. threeComponentDefinitions,
  431. threeComponents,
  432. ThreeCanvas,
  433. } from "@json-render/react-three-fiber";
  434. const catalog = defineCatalog(schema, {
  435. components: {
  436. Box: threeComponentDefinitions.Box,
  437. Sphere: threeComponentDefinitions.Sphere,
  438. AmbientLight: threeComponentDefinitions.AmbientLight,
  439. DirectionalLight: threeComponentDefinitions.DirectionalLight,
  440. GaussianSplat: threeComponentDefinitions.GaussianSplat,
  441. OrbitControls: threeComponentDefinitions.OrbitControls,
  442. },
  443. actions: {},
  444. });
  445. const { registry } = defineRegistry(catalog, {
  446. components: {
  447. Box: threeComponents.Box,
  448. Sphere: threeComponents.Sphere,
  449. AmbientLight: threeComponents.AmbientLight,
  450. DirectionalLight: threeComponents.DirectionalLight,
  451. GaussianSplat: threeComponents.GaussianSplat,
  452. OrbitControls: threeComponents.OrbitControls,
  453. },
  454. });
  455. <ThreeCanvas
  456. spec={spec}
  457. registry={registry}
  458. shadows
  459. camera={{ position: [5, 5, 5], fov: 50 }}
  460. style={{ width: "100%", height: "100vh" }}
  461. />;
  462. ```
  463. ### Next.js (Full Apps)
  464. ```typescript
  465. import type { NextAppSpec } from "@json-render/next";
  466. import { createNextApp } from "@json-render/next/server";
  467. import { NextAppProvider } from "@json-render/next";
  468. const spec: NextAppSpec = {
  469. metadata: { title: { default: "My App", template: "%s | My App" } },
  470. layouts: {
  471. main: {
  472. root: "shell",
  473. elements: {
  474. shell: { type: "Container", props: {}, children: ["nav", "slot"] },
  475. nav: { type: "NavBar", props: {}, children: [] },
  476. slot: { type: "Slot", props: {}, children: [] },
  477. },
  478. },
  479. },
  480. routes: {
  481. "/": {
  482. layout: "main",
  483. metadata: { title: "Home" },
  484. page: {
  485. root: "hero",
  486. elements: {
  487. hero: { type: "Card", props: { title: "Welcome" }, children: [] },
  488. },
  489. },
  490. },
  491. },
  492. };
  493. // Server: creates getPageData, generateMetadata, generateStaticParams
  494. const app = createNextApp({ spec });
  495. // Client: wrap your layout with NextAppProvider
  496. // <NextAppProvider registry={registry} handlers={handlers}>
  497. // {children}
  498. // </NextAppProvider>
  499. ```
  500. ### TanStack Start (Full Apps)
  501. ```tsx
  502. import { createFileRoute, notFound } from "@tanstack/react-router";
  503. import {
  504. PageRenderer,
  505. StartErrorBoundary,
  506. StartLoading,
  507. StartNotFound,
  508. type StartAppSpec,
  509. } from "@json-render/tanstack-start";
  510. import { createStartApp } from "@json-render/tanstack-start/server";
  511. const spec: StartAppSpec = {
  512. metadata: { title: { default: "My App", template: "%s | My App" } },
  513. routes: {
  514. "/": {
  515. metadata: { title: "Home" },
  516. page: {
  517. root: "hero",
  518. elements: {
  519. hero: { type: "Card", props: { title: "Welcome" }, children: [] },
  520. },
  521. },
  522. },
  523. },
  524. };
  525. const { getPageData, getHead } = createStartApp({ spec });
  526. export const Route = createFileRoute("/$")({
  527. loader: async ({ location }) => {
  528. const data = await getPageData({ pathname: location.pathname });
  529. if (!data) throw notFound();
  530. return data;
  531. },
  532. head: ({ match }) => getHead({ pathname: match.pathname }),
  533. component: () => <PageRenderer {...Route.useLoaderData()} />,
  534. pendingComponent: StartLoading,
  535. errorComponent: StartErrorBoundary,
  536. notFoundComponent: StartNotFound,
  537. });
  538. ```
  539. Wrap the root route's outlet with `<StartAppProvider spec={spec}>` so route
  540. fallback components can resolve the current route. Pass named `$computed`
  541. implementations through its `functions` prop.
  542. ### shadcn-svelte (Svelte)
  543. ```typescript
  544. import { defineCatalog } from "@json-render/core";
  545. import { schema } from "@json-render/svelte/schema";
  546. import { defineRegistry, Renderer } from "@json-render/svelte";
  547. import { shadcnComponentDefinitions } from "@json-render/shadcn-svelte/catalog";
  548. import { shadcnComponents } from "@json-render/shadcn-svelte";
  549. const catalog = defineCatalog(schema, {
  550. components: {
  551. Card: shadcnComponentDefinitions.Card,
  552. Stack: shadcnComponentDefinitions.Stack,
  553. Heading: shadcnComponentDefinitions.Heading,
  554. Button: shadcnComponentDefinitions.Button,
  555. },
  556. actions: {},
  557. });
  558. const { registry } = defineRegistry(catalog, {
  559. components: {
  560. Card: shadcnComponents.Card,
  561. Stack: shadcnComponents.Stack,
  562. Heading: shadcnComponents.Heading,
  563. Button: shadcnComponents.Button,
  564. },
  565. });
  566. // In your Svelte component:
  567. // <Renderer spec={spec} registry={registry} />
  568. ```
  569. ### Devtools
  570. Drop-in inspector panel for any json-render app. Spec tree, state editor, action log, stream log, catalog browser, DOM picker.
  571. ```tsx
  572. // React
  573. import { JsonRenderDevtools } from "@json-render/devtools-react";
  574. <JSONUIProvider registry={registry} handlers={handlers}>
  575. <Renderer spec={spec} registry={registry} />
  576. <JsonRenderDevtools spec={spec} catalog={catalog} messages={messages} />
  577. </JSONUIProvider>;
  578. ```
  579. Floating toggle appears bottom-right. Hotkey: `Ctrl`/`Cmd` + `Shift` + `J`. Tree-shakes to `null` in production.
  580. Available for React, Vue, Svelte, and Solid — swap `@json-render/devtools-react` for the adapter that matches your renderer.
  581. ### Ink (Terminal)
  582. ```tsx
  583. import { defineCatalog } from "@json-render/core";
  584. import {
  585. schema,
  586. standardComponentDefinitions,
  587. standardActionDefinitions,
  588. defineRegistry,
  589. Renderer,
  590. JSONUIProvider,
  591. } from "@json-render/ink";
  592. const catalog = defineCatalog(schema, {
  593. components: { ...standardComponentDefinitions },
  594. actions: standardActionDefinitions,
  595. });
  596. const { registry } = defineRegistry(catalog, { components: {} });
  597. const spec = {
  598. root: "card-1",
  599. elements: {
  600. "card-1": {
  601. type: "Card",
  602. props: { title: "Status" },
  603. children: ["status-1"],
  604. },
  605. "status-1": {
  606. type: "StatusLine",
  607. props: { label: "Build", status: "success" },
  608. children: [],
  609. },
  610. },
  611. };
  612. <JSONUIProvider initialState={{}}>
  613. <Renderer spec={spec} registry={registry} />
  614. </JSONUIProvider>;
  615. ```
  616. ## Features
  617. ### Streaming (SpecStream)
  618. Stream AI responses progressively:
  619. ```typescript
  620. import { createSpecStreamCompiler } from "@json-render/core";
  621. const compiler = createSpecStreamCompiler<MySpec>();
  622. // Process chunks as they arrive
  623. const { result, newPatches } = compiler.push(chunk);
  624. setSpec(result); // Update UI with partial result
  625. // Get final result
  626. const finalSpec = compiler.getResult();
  627. ```
  628. ### AI Prompt Generation
  629. Generate system prompts from your catalog:
  630. ```typescript
  631. const systemPrompt = catalog.prompt();
  632. // Includes component descriptions, props schemas, available actions
  633. ```
  634. ### Conditional Visibility
  635. ```json
  636. {
  637. "type": "Alert",
  638. "props": { "message": "Error occurred" },
  639. "visible": [
  640. { "$state": "/form/hasError" },
  641. { "$state": "/form/errorDismissed", "not": true }
  642. ]
  643. }
  644. ```
  645. ### Dynamic Props
  646. Any prop value can be data-driven using expressions:
  647. ```json
  648. {
  649. "type": "Icon",
  650. "props": {
  651. "name": {
  652. "$cond": { "$state": "/activeTab", "eq": "home" },
  653. "$then": "home",
  654. "$else": "home-outline"
  655. },
  656. "color": {
  657. "$cond": { "$state": "/activeTab", "eq": "home" },
  658. "$then": "#007AFF",
  659. "$else": "#8E8E93"
  660. }
  661. }
  662. }
  663. ```
  664. Expression forms:
  665. - **`{ "$state": "/state/key" }`** - reads a value from the state model
  666. - **`{ "$cond": <condition>, "$then": <value>, "$else": <value> }`** - evaluates a condition and picks a branch
  667. - **`{ "$template": "Hello, ${/user/name}!" }`** - interpolates state values into strings
  668. - **`{ "$computed": "fn", "args": { ... } }`** - calls a registered function with resolved args
  669. ### Actions
  670. Components can trigger actions, including the built-in `setState` action:
  671. ```json
  672. {
  673. "type": "Pressable",
  674. "props": {
  675. "action": "setState",
  676. "actionParams": { "statePath": "/activeTab", "value": "home" }
  677. },
  678. "children": ["home-icon"]
  679. }
  680. ```
  681. The `setState` action updates the state model directly, which re-evaluates visibility conditions and dynamic prop expressions.
  682. ### State Watchers
  683. React to state changes by triggering actions:
  684. ```json
  685. {
  686. "type": "Select",
  687. "props": {
  688. "value": { "$bindState": "/form/country" },
  689. "options": ["US", "Canada", "UK"]
  690. },
  691. "watch": {
  692. "/form/country": {
  693. "action": "loadCities",
  694. "params": { "country": { "$state": "/form/country" } }
  695. }
  696. }
  697. }
  698. ```
  699. `watch` is a top-level field on elements (sibling of `type`/`props`/`children`). Watchers fire when the watched value changes, not on initial render.
  700. ---
  701. ## Demo
  702. ```bash
  703. git clone https://github.com/vercel-labs/json-render
  704. cd json-render
  705. pnpm install
  706. pnpm dev
  707. ```
  708. - http://json-render.localhost:1355 - Docs & Playground
  709. - http://dashboard-demo.json-render.localhost:1355 - Example Dashboard
  710. - http://react-email-demo.json-render.localhost:1355 - React Email Example
  711. - http://remotion-demo.json-render.localhost:1355 - Remotion Video Example
  712. - Chat Example: run `pnpm dev` in `examples/chat`
  713. - http://chat-sdk-demo.json-render.localhost:1355 - Chat SDK Example
  714. - [Experimental Jev composition](https://json-render.dev/docs/jev): use `experimental_composeSpec` and `experimental_createEvaluator` from core with your own catalog, or select **Jev (Experimental)** in `/playground`. Available since v0.21.0; pin exact package versions as described in the guide.
  715. - Svelte Example: run `pnpm dev` in `examples/svelte` or `examples/svelte-chat`
  716. - Vue Example: run `pnpm dev` in `examples/vue`
  717. - Vite Renderers (React + Vue + Svelte + Solid): run `pnpm dev` in `examples/vite-renderers`
  718. - React Native example: run `npx expo start` in `examples/react-native`
  719. - Gaussian Splatting (R3F): run `pnpm dev` in `examples/react-three-fiber-gsplat`
  720. - Gaussian Splatting (experimental standalone gsplat.js demo): run `pnpm dev` in `examples/gsplat`
  721. ## How It Works
  722. ```mermaid
  723. flowchart LR
  724. A[User Prompt] --> B[AI + Catalog]
  725. B --> C[JSON Spec]
  726. C --> D[Renderer]
  727. B -.- E([guardrailed])
  728. C -.- F([predictable])
  729. D -.- G([streamed])
  730. ```
  731. 1. **Define the guardrails** - what components, actions, and data bindings AI can use
  732. 2. **Prompt** - describe what you want in natural language
  733. 3. **AI generates JSON** - output is always predictable, constrained to your catalog
  734. 4. **Render fast** - stream and render progressively as the model responds
  735. ## License
  736. Apache-2.0

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.