All blocks
BlocksArtifacts

JSON Render Shadcn

Use this when prompts should render only from a fixed catalog of shadcn components provided by the @json-render/shadcn package.

Loading pattern preview

Problems solved

Technical challenges this implementation handles out of the box.
  • Build UIs from natural-language prompts with json-render
  • Stream AI-generated component specs into a live preview
  • Render shadcn components from a constrained catalog

Use cases

Products and workflows this pattern is designed to support.
  • UI playgrounds for prompt-to-interface
  • Dashboard builders
  • Form generators
  • Design-to-shadcn prototyping

Compare with

Similar patterns, and when each one is the better fit.

Setup

Requirements, wiring steps, and what this pattern adds to your project.

Getting started

Pick how you want to pull this pattern in. Then wire env vars and routes the same way.

  1. 1

    Download → Next.js app

    Use Download → Next.js app in the preview toolbar. You get a zip scaffold (Pro downloads rewrite preview `/view/.../api/*` paths to `/api/*` automatically).

  2. 2

    Extract the zip and install dependencies

    Unzip the archive, then run `pnpm install` (or npm / yarn) in the project folder.

  3. 3

    Fill .env.local

    The download includes .env.local placeholders when needed. Add real values for: AI_GATEWAY_API_KEY.

  4. 4

    Customize the agent and tool files

    Adapt prompts, tools, and stop conditions in the generated project for your product.

  5. 5

    Run the app and open the pattern route

    Run `pnpm dev`, open the setup/checklist page if present, then navigate to the generated pattern route and verify responses.

Environment variables

Capabilities

AI SDK APIs

streamTextgateway

Providers

OpenAI

External services

Upstash

Files added

10 files
  • app/page.tsx
  • app/layout.tsx
  • app/api/json-render-shadcn/route.ts
  • components/json-render-demo.tsx
  • components/empty-state.tsx
  • lib/catalog.ts
  • lib/registry.tsx
  • lib/rate-limit.ts
  • lib/request-utils.ts
  • README.md

Dependencies

15 total

npm packages

11
AISDK@json-render/core@json-render/react@json-render/shadcnUpstashlucide-reactNext.jsReactZodmotionsonner

Shadcn IconRegistry components

4
buttonemptyinputscroll-area

Critical files

3 files
  • lib/catalog.ts

    Defines the json-render catalog using defineCatalog with shadcn component definitions. This is the component registry that maps JSON spec types to renderable shadcn components.

  • lib/registry.tsx

    React component registry mapping json-render component names to actual shadcn/ui React components. Used by the renderer to resolve components at runtime.

  • json-render-shadcn/route.ts

    Streaming API endpoint. Uses catalog.prompt() to generate the system prompt, streams AI-generated JSON specs via streamText with gateway('google/gemini-3-flash').

Requirements

Complexity
Intermediate
Setup time
~5 minutes
Node
24+
Memory
256MB
Upstash Redis