Lightweight JSON UI tooling for React Native with the Vercel AI SDK. The model builds and updates a UI by calling tools (e.g. add node, set props); you render the resulting spec with GenerativeUIView.
GEN_UI_NODE_HINTS, GEN_UI_STYLES, GEN_UI_NODE_NAMES for tools and promptscreateGenUITools for JSON UI mutation (get/add/delete nodes, set props, reorder)buildGenUISystemPrompt for model instructionsGenerativeUIView passes GEN_UI_STYLES (overridable) to the default GenUINode and supports a custom node rendererThere exists a great library for streaming interfaces: json-render. The full specification is provided in the 'Prior art' section, but TL;DR: this library - @react-native-ai/json-ui - is the choice for small language models (e.g. parameters in the order of magnitude of 3B), which is usually the case if you are running inference locally, on-device. If you are using a cloud provider, consider json-render instead.
streamText, generateText, etc.)Finally, render the spec set by updateSpec in your app with GenerativeUIView (see Generative UI View):
For a full usage example, see this file.
The package exports these registry constants (used by tools and the default renderer):
GEN_UI_NODE_NAMES — canonical node type names (Text, Paragraph, Label, Heading, Button, TextInput)GEN_UI_NODE_HINTS — short descriptions for each node type (for prompts)GEN_UI_NODE_NAMES_THAT_SUPPORT_CHILDREN — node types that can have childrenGEN_UI_STYLES — zod schemas for style props (flex, padding, gap, backgroundColor, color, etc.)GEN_UI_STYLE_HINTS — metadata for style keys (for prompt text)GEN_UI_STYLES.