<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/streaming-generative-ui-with-json-react-server-components-xizyryb1e" -->

---
title: Streaming Generative UI with JSON & React Server Components
description: A detailed technical walkthrough builds a streaming Generative UI system in Next.js 15+ and React 19, replacing the common LLM-to-Markdown-to-HTML pattern with...
canonical: https://daily.dev/posts/streaming-generative-ui-with-json-react-server-components-xizyryb1e
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Streaming Generative UI with JSON & React Server Components | daily.dev
og:description: A detailed technical walkthrough builds a streaming Generative UI system in Next.js 15+ and React 19, replacing the common LLM-to-Markdown-to-HTML pattern with...
og:url: https://daily.dev/posts/streaming-generative-ui-with-json-react-server-components-xizyryb1e
og:image: https://api.daily.dev/og/posts/XizyRYB1e.png
og:image:alt: Streaming Generative UI with JSON & React Server Components
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Streaming Generative UI with JSON & React Server Components

**[SitePoint](https://daily.dev/sources/sitepoint)** · 23 min read · 0 upvotes · 0 comments

## Summary

A detailed technical walkthrough builds a streaming Generative UI system in Next.js 15+ and React 19, replacing the common LLM-to-Markdown-to-HTML pattern with structured JSON streamed directly into typed React components. It covers writing an incremental JSON stream parser using the Web Streams API with brace-depth counting, defining a recursive discriminated UINode schema with Zod for validation, building a component registry that maps schema variants to React components, wiring a Next.js Route Handler that strips SSE framing from an OpenAI-compatible LLM response and returns NDJSON, and consuming that stream client-side with React 19's async useTransition pattern. It also addresses layout-shift prevention via CSS containment and skeleton sizing, backpressure limits, error boundaries, and observability metrics like time-to-first-component. The approach avoids proprietary AI SDKs (no ai/rsc, no Vercel AI SDK), relying only on Zod as an added dependency.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.sitepoint.com/streaming-generative-ui-react-server-components>

## Questions this post answers

### Why is streaming JSON better than converting LLM Markdown output to HTML for generative UI?

Streaming JSON avoids layout shifts and adds real type safety, unlike Markdown-to-HTML which reflows as content converts and offers no validation. Each JSON component carries its own layout constraints (a card knows its width, a chart reserves its height), so components mount in final dimensions. JSON also enables composability, letting components nest, carry complex props, and trigger Server Actions, which flat HTML cannot support.

_daily.dev surfaces deep dives like this for developers weighing generative UI architectures for LLM apps._

### Does OpenAI's response_format json_object mode work for streaming NDJSON-style generative UI components?

No, OpenAI's response_format: { type: "json_object" } guarantees the entire response is one single valid JSON object rather than multiple newline-delimited objects, so it is not suitable for NDJSON streaming approaches. Structured output mode enforces valid JSON schemas but not all models support it, and even supporting models occasionally produce malformed output.

_developers wiring LLM APIs into streaming UIs can track these API behavior details on daily.dev._

### Why does the async startTransition(async () => {...}) pattern require React 19 instead of React 18?

In React 18, passing an async function to startTransition causes isPending to flip back to false immediately after the async call starts, rather than staying true throughout the operation. React 19 fixes this so isPending correctly reflects the pending state of the entire async transition, which matters for showing loading UI during streaming fetches. On React 18, loading state must be managed with a separate useState boolean instead.

_teams upgrading to React 19 can keep tabs on behavior changes like this via daily.dev._

## Similar posts on daily.dev

- [Exploring Vercel’s JSON Render: build dynamic UI from structured data](https://daily.dev/posts/exploring-vercel-s-json-render-build-dynamic-ui-from-structured-data-6njjmlpre) · LogRocket · 2 upvotes · 0 comments
- [Vercel Releases JSON-Render: A Generative UI Framework for AI-Driven Interface Composition](https://daily.dev/posts/vercel-releases-json-render-a-generative-ui-framework-for-ai-driven-interface-composition-msfa6nj8a) · InfoQ · 9 upvotes · 0 comments
- [A better approach to generative UI](https://daily.dev/posts/a-better-approach-to-generative-ui-hwpqccf9w) · InfoWorld · 0 upvotes · 0 comments
- [Next.js AI Streaming: Building Real-Time Apps with Vercel AI SDK](https://daily.dev/posts/next-js-ai-streaming-building-real-time-apps-with-vercel-ai-sdk-yrhbezzlx) · SitePoint · 1 upvotes · 0 comments
- [Markdown as a Protocol for Agentic UI](https://daily.dev/posts/markdown-as-a-protocol-for-agentic-ui-ox4zmtr3b) · Hacker News · 6 upvotes · 1 comments

---

Tags: [#react](https://daily.dev/tags/react), [#nextjs](https://daily.dev/tags/nextjs), [#zod](https://daily.dev/tags/zod), [#generative-ui](https://daily.dev/tags/generative-ui)

[View this post on daily.dev](https://daily.dev/posts/streaming-generative-ui-with-json-react-server-components-xizyryb1e)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Streaming Generative UI with JSON \u0026 React Server Components","url":"https://daily.dev/posts/streaming-generative-ui-with-json-react-server-components-xizyryb1e","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/streaming-generative-ui-with-json-react-server-components-xizyryb1e"},"datePublished":"2026-09-20T15:32:34.144Z","dateModified":"2026-09-20T15:33:00.221Z","description":"A detailed technical walkthrough builds a streaming Generative UI system in Next.js 15+ and React 19, replacing the common LLM-to-Markdown-to-HTML pattern with...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7d2a55deb05252e1a53f91c6eabb6bac?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7d2a55deb05252e1a53f91c6eabb6bac?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"SitePoint","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"SitePoint","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/sitepoint","url":"https://daily.dev/sources/sitepoint"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/streaming-generative-ui-with-json-react-server-components-xizyryb1e","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"react,nextjs,zod,generative-ui","timeRequired":"PT23M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"SitePoint","item":"https://daily.dev/sources/sitepoint"},{"@type":"ListItem","position":3,"name":"Streaming Generative UI with JSON \u0026 React Server Components"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/streaming-generative-ui-with-json-react-server-components-xizyryb1e#faq","mainEntity":[{"@type":"Question","name":"Why is streaming JSON better than converting LLM Markdown output to HTML for generative UI?","acceptedAnswer":{"@type":"Answer","text":"Streaming JSON avoids layout shifts and adds real type safety, unlike Markdown-to-HTML which reflows as content converts and offers no validation. Each JSON component carries its own layout constraints (a card knows its width, a chart reserves its height), so components mount in final dimensions. JSON also enables composability, letting components nest, carry complex props, and trigger Server Actions, which flat HTML cannot support. daily.dev surfaces deep dives like this for developers weighing generative UI architectures for LLM apps."}},{"@type":"Question","name":"Does OpenAI's response_format json_object mode work for streaming NDJSON-style generative UI components?","acceptedAnswer":{"@type":"Answer","text":"No, OpenAI's response_format: { type: \"json_object\" } guarantees the entire response is one single valid JSON object rather than multiple newline-delimited objects, so it is not suitable for NDJSON streaming approaches. Structured output mode enforces valid JSON schemas but not all models support it, and even supporting models occasionally produce malformed output. developers wiring LLM APIs into streaming UIs can track these API behavior details on daily.dev."}},{"@type":"Question","name":"Why does the async startTransition(async () =\u003e {...}) pattern require React 19 instead of React 18?","acceptedAnswer":{"@type":"Answer","text":"In React 18, passing an async function to startTransition causes isPending to flip back to false immediately after the async call starts, rather than staying true throughout the operation. React 19 fixes this so isPending correctly reflects the pending state of the entire async transition, which matters for showing loading UI during streaming fetches. On React 18, loading state must be managed with a separate useState boolean instead. teams upgrading to React 19 can keep tabs on behavior changes like this via daily.dev."}}]}
```

