page.tsx 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. <h1 className="text-4xl sm:text-5xl md:text-7xl font-bold tracking-tighter mb-6">
  12. JSON becomes UI
  13. </h1>
  14. <p className="text-lg text-muted-foreground max-w-2xl mx-auto mb-12 leading-relaxed">
  15. Define a catalog. AI generates JSON. Your components render natively.
  16. </p>
  17. <Demo />
  18. <div className="flex items-center justify-center gap-2 border border-border rounded px-4 py-3 mt-12 mx-auto w-fit">
  19. <code className="text-sm bg-transparent">npm install @json-render/core @json-render/react</code>
  20. <CopyButton text="npm install @json-render/core @json-render/react" />
  21. </div>
  22. <div className="flex gap-3 justify-center mt-6">
  23. <Button size="lg" asChild>
  24. <Link href="/docs">Get Started</Link>
  25. </Button>
  26. <Button size="lg" variant="outline" asChild>
  27. <a
  28. href="https://github.com/vercel-labs/json-render"
  29. target="_blank"
  30. rel="noopener noreferrer"
  31. >
  32. <svg
  33. viewBox="0 0 24 24"
  34. fill="currentColor"
  35. className="w-5 h-5"
  36. >
  37. <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" />
  38. </svg>
  39. GitHub
  40. </a>
  41. </Button>
  42. </div>
  43. </section>
  44. {/* How it works */}
  45. <section className="border-t border-border">
  46. <div className="max-w-5xl mx-auto px-6 py-24">
  47. <div className="grid md:grid-cols-3 gap-12">
  48. <div>
  49. <div className="text-xs text-muted-foreground font-mono mb-3">01</div>
  50. <h3 className="text-lg font-semibold mb-2">Define Catalog</h3>
  51. <p className="text-sm text-muted-foreground leading-relaxed">
  52. Specify which components AI can use with Zod schemas. Full type safety and validation.
  53. </p>
  54. </div>
  55. <div>
  56. <div className="text-xs text-muted-foreground font-mono mb-3">02</div>
  57. <h3 className="text-lg font-semibold mb-2">Register Components</h3>
  58. <p className="text-sm text-muted-foreground leading-relaxed">
  59. Map catalog types to your React components. Use your own design system.
  60. </p>
  61. </div>
  62. <div>
  63. <div className="text-xs text-muted-foreground font-mono mb-3">03</div>
  64. <h3 className="text-lg font-semibold mb-2">Let AI Generate</h3>
  65. <p className="text-sm text-muted-foreground leading-relaxed">
  66. AI outputs JSON matching your schema. Stream it. Render progressively.
  67. </p>
  68. </div>
  69. </div>
  70. </div>
  71. </section>
  72. {/* Code example */}
  73. <section className="border-t border-border">
  74. <div className="max-w-5xl mx-auto px-6 py-24">
  75. <div className="grid lg:grid-cols-2 gap-12">
  76. <div>
  77. <h2 className="text-2xl font-semibold mb-4">Define your catalog</h2>
  78. <p className="text-muted-foreground mb-6">
  79. Components, actions, and validation functions.
  80. </p>
  81. <Code lang="typescript">{`import { createCatalog } from '@json-render/core';
  82. import { z } from 'zod';
  83. export const catalog = createCatalog({
  84. components: {
  85. Card: {
  86. props: z.object({
  87. title: z.string(),
  88. description: z.string().nullable(),
  89. }),
  90. hasChildren: true,
  91. },
  92. Metric: {
  93. props: z.object({
  94. label: z.string(),
  95. valuePath: z.string(),
  96. format: z.enum(['currency', 'percent']),
  97. }),
  98. },
  99. },
  100. actions: {
  101. export: { params: z.object({ format: z.string() }) },
  102. },
  103. });`}</Code>
  104. </div>
  105. <div>
  106. <h2 className="text-2xl font-semibold mb-4">AI generates JSON</h2>
  107. <p className="text-muted-foreground mb-6">
  108. Constrained output that your components render natively.
  109. </p>
  110. <Code lang="json">{`{
  111. "key": "dashboard",
  112. "type": "Card",
  113. "props": {
  114. "title": "Revenue Dashboard",
  115. "description": null
  116. },
  117. "children": [
  118. {
  119. "key": "revenue",
  120. "type": "Metric",
  121. "props": {
  122. "label": "Total Revenue",
  123. "valuePath": "/metrics/revenue",
  124. "format": "currency"
  125. }
  126. }
  127. ]
  128. }`}</Code>
  129. </div>
  130. </div>
  131. </div>
  132. </section>
  133. {/* Features */}
  134. <section className="border-t border-border">
  135. <div className="max-w-5xl mx-auto px-6 py-24">
  136. <h2 className="text-2xl font-semibold mb-12 text-center">Features</h2>
  137. <div className="grid sm:grid-cols-2 lg:grid-cols-3 gap-8">
  138. {[
  139. { title: "Guardrails", desc: "AI can only use components you define in the catalog" },
  140. { title: "Streaming", desc: "Progressive rendering as JSON streams from the model" },
  141. { title: "Data Binding", desc: "Two-way binding with JSON Pointer paths" },
  142. { title: "Actions", desc: "Named actions handled by your application" },
  143. { title: "Visibility", desc: "Conditional show/hide based on data or auth" },
  144. { title: "Validation", desc: "Built-in and custom validation functions" },
  145. ].map((feature) => (
  146. <div key={feature.title}>
  147. <h3 className="font-semibold mb-2">{feature.title}</h3>
  148. <p className="text-sm text-muted-foreground">{feature.desc}</p>
  149. </div>
  150. ))}
  151. </div>
  152. </div>
  153. </section>
  154. {/* CTA */}
  155. <section className="border-t border-border">
  156. <div className="max-w-4xl mx-auto px-6 py-24 text-center">
  157. <h2 className="text-2xl font-semibold mb-4">Get started</h2>
  158. <div className="flex items-center justify-center gap-2 border border-border rounded px-4 py-3 mb-8 mx-auto w-fit">
  159. <code className="text-sm bg-transparent">npm install @json-render/core @json-render/react</code>
  160. <CopyButton text="npm install @json-render/core @json-render/react" />
  161. </div>
  162. <div>
  163. <Button asChild>
  164. <Link href="/docs">Documentation</Link>
  165. </Button>
  166. </div>
  167. </div>
  168. </section>
  169. </>
  170. );
  171. }