vercel-labs / vercel-labs/json-render
Not able to generate UI by following "Quick Start" example
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 901
- Avg merge
- 3h 14m
- Merged PRs (30d)
- 4
Description
I followed the "Quick Start" example from the docs and I couldn't get it to work as expected and generate an UI from a tree. I noticed that the tree is always empty regardless of the stage of the stream, the tree is empty from the start until the end of it.
Looking at the two generate API routes available on this repo (dashboard example and the one from the website), I noticed that neither of them are generating the system prompt from the generateCatalogPrompt function. One is entirely hardcoded, while the other has the componentList being taken out from the catalog and the rest is also hardcoded.
Considering that, I followed the same approach and was able to generate UI. Should it actually have worked using generateCatalogPrompt? The docs should be updated and include a hardcoded system prompt?
This is the system prompt I used to make it work:
const SYSTEM_PROMPT = `You are a UI generator that outputs JSONL (JSON Lines) patches.
AVAILABLE COMPONENTS:
- Card: { title: string, description?: string } - Container with title and optional description
- Button: { label: string, action: string } - Clickable button with action
- Text: { content: string } - Text content
AVAILABLE ACTIONS:
- submit: { formId: string } - Submit form action
- navigate: { url: string } - Navigate to URL action
OUTPUT FORMAT:
Output JSONL where each line is a patch operation using a flat key-based structure:
OPERATIONS:
- {"op":"set","path":"/root","value":"root-key"} - Set root element
- {"op":"add","path":"/elements/element-key","value":{...}} - Add element
ELEMENT STRUCTURE:
{
"key": "unique-key",
"type": "ComponentType",
"props": { ... },
"children": ["child-key-1", "child-key-2"]
}
RULES:
1. First set /root to root element key
2. Add each element with unique key
3. Parent elements list child keys in children array
4. Stream progressively - parent first, then children
5. Each element must have: key, type, props
`;
In case it helps, I created this minimal reproduction of the "Quick Start" code.
PS.: also noticed that the Renderer's registry prop type isn't matching the return type from the registry object. Although explicitly typing it ComponentRegistry solves the type mismatch, it then creates another type issue with onAction as it doesn't expect 2 arguments even though there are 2 args in the snippet.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Quick Start documentation and compare it with examples/dashboard/app/api/generate/route.ts and apps/web/app/api/generate/route.ts, focusing on generateCatalogPrompt. Review the Renderer registry prop and onAction typing mentioned in the report, and consult the linked minimal reproduction. Done means the documented Quick Start generates a non-empty tree and the reported TypeScript mismatches are resolved or accurately documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100