page.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. import Link from "next/link";
  2. import { Button } from "@/components/ui/button";
  3. import { Demo } from "@/components/demo";
  4. import { Code } from "@/components/code";
  5. import { CopyButton } from "@/components/copy-button";
  6. export default function Home() {
  7. return (
  8. <>
  9. {/* Hero */}
  10. <section className="max-w-5xl mx-auto px-6 pt-24 pb-16 text-center">
  11. <p className="text-xs sm:text-sm font-medium text-muted-foreground tracking-widest uppercase mb-4">
  12. The framework for User-Generated Interfaces
  13. </p>
  14. <h1 className="text-4xl sm:text-6xl md:text-7xl font-bold tracking-tighter mb-6">
  15. AI → json-render → UI
  16. </h1>
  17. <p className="text-lg text-muted-foreground max-w-2xl mx-auto mb-12 leading-relaxed">
  18. Dynamic, personalized UIs per user without sacrificing reliability.
  19. Predefined components and actions for safe, predictable output.
  20. </p>
  21. <Demo />
  22. <div className="flex items-center justify-center gap-2 border border-border rounded px-4 py-3 mt-12 mx-auto w-fit">
  23. <code className="text-sm bg-transparent">
  24. npm install @json-render/core @json-render/react
  25. </code>
  26. <CopyButton text="npm install @json-render/core @json-render/react" />
  27. </div>
  28. <div className="flex gap-3 justify-center mt-6">
  29. <Button size="lg" asChild>
  30. <Link href="/docs">Get Started</Link>
  31. </Button>
  32. <Button size="lg" variant="outline" asChild>
  33. <a
  34. href="https://github.com/vercel-labs/json-render"
  35. target="_blank"
  36. rel="noopener noreferrer"
  37. >
  38. <svg viewBox="0 0 24 24" fill="currentColor" className="w-5 h-5">
  39. <path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" />
  40. </svg>
  41. GitHub
  42. </a>
  43. </Button>
  44. </div>
  45. </section>
  46. {/* How it works */}
  47. <section className="border-t border-border">
  48. <div className="max-w-5xl mx-auto px-6 py-24">
  49. <div className="grid md:grid-cols-3 gap-12">
  50. <div>
  51. <div className="text-xs text-muted-foreground font-mono mb-3">
  52. 01
  53. </div>
  54. <h3 className="text-lg font-semibold mb-2">
  55. Define Your Catalog
  56. </h3>
  57. <p className="text-sm text-muted-foreground leading-relaxed">
  58. Set the guardrails. Define which components, actions, and data
  59. bindings AI can use.
  60. </p>
  61. </div>
  62. <div>
  63. <div className="text-xs text-muted-foreground font-mono mb-3">
  64. 02
  65. </div>
  66. <h3 className="text-lg font-semibold mb-2">Users Generate</h3>
  67. <p className="text-sm text-muted-foreground leading-relaxed">
  68. End users describe what they want. AI generates JSON constrained
  69. to your catalog. Every interface is unique to the user.
  70. </p>
  71. </div>
  72. <div>
  73. <div className="text-xs text-muted-foreground font-mono mb-3">
  74. 03
  75. </div>
  76. <h3 className="text-lg font-semibold mb-2">Render Instantly</h3>
  77. <p className="text-sm text-muted-foreground leading-relaxed">
  78. Stream the response. Your components render progressively as
  79. JSON arrives.
  80. </p>
  81. </div>
  82. </div>
  83. </div>
  84. </section>
  85. {/* Code example */}
  86. <section className="border-t border-border">
  87. <div className="max-w-5xl mx-auto px-6 py-24">
  88. <div className="grid lg:grid-cols-2 gap-12">
  89. <div className="min-w-0">
  90. <h2 className="text-2xl font-semibold mb-4">
  91. Define your catalog
  92. </h2>
  93. <p className="text-muted-foreground mb-6">
  94. Components, actions, and validation functions.
  95. </p>
  96. <Code lang="typescript">{`import { createCatalog } from '@json-render/core';
  97. import { z } from 'zod';
  98. export const catalog = createCatalog({
  99. components: {
  100. Card: {
  101. props: z.object({
  102. title: z.string(),
  103. description: z.string().nullable(),
  104. }),
  105. hasChildren: true,
  106. },
  107. Metric: {
  108. props: z.object({
  109. label: z.string(),
  110. valuePath: z.string(),
  111. format: z.enum(['currency', 'percent']),
  112. }),
  113. },
  114. },
  115. actions: {
  116. export: { params: z.object({ format: z.string() }) },
  117. },
  118. });`}</Code>
  119. </div>
  120. <div className="min-w-0">
  121. <h2 className="text-2xl font-semibold mb-4">AI generates JSON</h2>
  122. <p className="text-muted-foreground mb-6">
  123. Constrained output that your components render natively.
  124. </p>
  125. <Code lang="json">{`{
  126. "root": "dashboard",
  127. "elements": {
  128. "dashboard": {
  129. "type": "Card",
  130. "props": {
  131. "title": "Revenue Dashboard"
  132. },
  133. "children": ["revenue"]
  134. },
  135. "revenue": {
  136. "type": "Metric",
  137. "props": {
  138. "label": "Total Revenue",
  139. "valuePath": "/metrics/revenue",
  140. "format": "currency"
  141. }
  142. }
  143. }
  144. }`}</Code>
  145. </div>
  146. </div>
  147. </div>
  148. </section>
  149. {/* Code Export */}
  150. <section className="border-t border-border">
  151. <div className="max-w-5xl mx-auto px-6 py-24">
  152. <div className="text-center mb-12">
  153. <h2 className="text-2xl font-semibold mb-4">Export as Code</h2>
  154. <p className="text-muted-foreground max-w-2xl mx-auto">
  155. Export generated UI as standalone React components. No runtime
  156. dependencies required.
  157. </p>
  158. </div>
  159. <div className="grid lg:grid-cols-2 gap-12">
  160. <div className="min-w-0">
  161. <h3 className="text-lg font-semibold mb-4">Generated UI Tree</h3>
  162. <p className="text-muted-foreground mb-6 text-sm">
  163. AI generates a JSON structure from the user&apos;s prompt.
  164. </p>
  165. <Code lang="json">{`{
  166. "root": "card",
  167. "elements": {
  168. "card": {
  169. "type": "Card",
  170. "props": { "title": "Revenue" },
  171. "children": ["metric", "chart"]
  172. },
  173. "metric": {
  174. "type": "Metric",
  175. "props": {
  176. "label": "Total Revenue",
  177. "valuePath": "analytics/revenue",
  178. "format": "currency"
  179. }
  180. },
  181. "chart": {
  182. "type": "Chart",
  183. "props": {
  184. "statePath": "analytics/salesByRegion"
  185. }
  186. }
  187. }
  188. }`}</Code>
  189. </div>
  190. <div className="min-w-0">
  191. <h3 className="text-lg font-semibold mb-4">
  192. Exported React Code
  193. </h3>
  194. <p className="text-muted-foreground mb-6 text-sm">
  195. Export as a standalone Next.js project with all components.
  196. </p>
  197. <Code lang="tsx">{`"use client";
  198. import { Card, Metric, Chart } from "@/components/ui";
  199. const data = {
  200. analytics: {
  201. revenue: 125000,
  202. salesByRegion: [
  203. { label: "US", value: 45000 },
  204. { label: "EU", value: 35000 },
  205. ],
  206. },
  207. };
  208. export default function Page() {
  209. return (
  210. <Card data={data} title="Revenue">
  211. <Metric
  212. data={data}
  213. label="Total Revenue"
  214. valuePath="analytics/revenue"
  215. format="currency"
  216. />
  217. <Chart data={data} statePath="analytics/salesByRegion" />
  218. </Card>
  219. );
  220. }`}</Code>
  221. </div>
  222. </div>
  223. <div className="mt-8 text-center">
  224. <p className="text-sm text-muted-foreground">
  225. The export includes{" "}
  226. <code className="text-foreground">package.json</code>, component
  227. files, styles, and everything needed to run independently.
  228. </p>
  229. </div>
  230. </div>
  231. </section>
  232. {/* Features */}
  233. <section className="border-t border-border">
  234. <div className="max-w-5xl mx-auto px-6 py-24">
  235. <h2 className="text-2xl font-semibold mb-12 text-center">Features</h2>
  236. <div className="grid sm:grid-cols-2 lg:grid-cols-3 gap-8">
  237. {[
  238. {
  239. title: "User-Generated Interfaces",
  240. desc: "Dynamic, personalized UIs per user powered by Generative UI",
  241. },
  242. {
  243. title: "Guardrails",
  244. desc: "AI can only use components you define in the catalog",
  245. },
  246. {
  247. title: "Streaming",
  248. desc: "Progressive rendering as JSON streams from the model",
  249. },
  250. {
  251. title: "React & React Native",
  252. desc: "Render on web and mobile from the same catalog and spec format",
  253. },
  254. {
  255. title: "Data Binding",
  256. desc: "Two-way state binding with dynamic prop expressions",
  257. },
  258. {
  259. title: "Code Export",
  260. desc: "Export as standalone React code with no runtime dependencies",
  261. },
  262. ].map((feature) => (
  263. <div key={feature.title}>
  264. <h3 className="font-semibold mb-2">{feature.title}</h3>
  265. <p className="text-sm text-muted-foreground">{feature.desc}</p>
  266. </div>
  267. ))}
  268. </div>
  269. </div>
  270. </section>
  271. {/* CTA */}
  272. <section className="border-t border-border">
  273. <div className="max-w-4xl mx-auto px-6 py-24 text-center">
  274. <h2 className="text-2xl font-semibold mb-4">Get started</h2>
  275. <div className="flex items-center justify-center gap-2 border border-border rounded px-4 py-3 mb-8 mx-auto w-fit">
  276. <code className="text-sm bg-transparent">
  277. npm install @json-render/core @json-render/react
  278. </code>
  279. <CopyButton text="npm install @json-render/core @json-render/react" />
  280. </div>
  281. <div>
  282. <Button asChild>
  283. <Link href="/docs">Documentation</Link>
  284. </Button>
  285. </div>
  286. </div>
  287. </section>
  288. </>
  289. );
  290. }