The Future of React: AI-Driven Components
Generative UI is starting to work, and it is rough. What model-picked components can do in early 2024, what they can't, and why the registry pattern is the part that matters.
System Genai Team/2 min read
Right now "AI components" mostly means a chatbot bolted onto a marketing site. That is a shame, because the interesting work is happening one level down: components whose structure gets decided at request time by a model.
Generative UI
Vercel's v0 already turns prompts into React components at build time. The next step is doing it at request time: the server asks a model which component fits the data, then streams that component to the client. React Server Components make this less insane than it sounds, since both the decision and the render happen on the server and the client just receives UI.
// Conceptual: a server component that lets the model choose from a registry
import { registry } from './registry';
export default async function GenerativeAnswer({ prompt }) {
const { component, props } = await pickComponent(prompt, Object.keys(registry));
const Comp = registry[component];
return <Comp {...props} />;
}
The constraint that keeps this shippable: the model picks from a registry of components you wrote and validates props against a schema. Letting it emit arbitrary JSX is a security incident with extra steps.
Smarter forms
The less flashy, more immediately useful version is forms that correct themselves. An address field that resolves "the tall building by the station" into an actual address. A date input that accepts "next Tuesday". One call to OpenAI or Anthropic behind a debounce. The hard part is not the API call, it is deciding when a correction helps and when the form is arguing with the user. Always show what changed, and make undo one click.
What this does to the job
Nobody is getting replaced by a component that hallucinates its own props. The work shifts, though:
- Prompts become an interface contract, and they need code review like one.
- State management has to tolerate outputs that arrive wrong, late, or not at all.
- Streaming render performance stops being an edge case and becomes Tuesday.
Where this lands
Our bet: within a couple of years, "the model picked this layout" will be as unremarkable as "the CMS picked this layout" is today. The teams in good shape then will be the ones who treated model output as untrusted input from day one.
Related reading
Top 5 React Libraries for Building AI InterfacesThe five libraries that end up in almost every AI interface we ship, and the caveats we wish someone had told us about each one.Resources2 min readOptimizing LLM Integrations in ReactModel inference is slow and metered per token. Most of the fix lives in the UI layer: optimistic rendering, debounced requests, and counting tokens before you send them.Optimization2 min readCase Study: Scaling AI Workflows with ReactNotes from building a drag and drop agent pipeline editor with React Flow and Zustand, including the render problems that showed up past a few hundred nodes.Case Study2 min read