page.tsx 5.8 KB

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