Loading...
Loading...
React Native renderer for json-render that turns JSON specs into native mobile UIs. Use when working with @json-render/react-native, building React Native UIs from JSON, creating mobile component catalogs, or rendering AI-generated specs on mobile.
npx skill4agent add vercel-labs/json-render json-render-react-nativeimport { defineCatalog } from "@json-render/core";
import { schema } from "@json-render/react-native/schema";
import {
standardComponentDefinitions,
standardActionDefinitions,
} from "@json-render/react-native/catalog";
import { defineRegistry, Renderer, type Components } from "@json-render/react-native";
import { z } from "zod";
// Create catalog with standard + custom components
const catalog = defineCatalog(schema, {
components: {
...standardComponentDefinitions,
Icon: {
props: z.object({ name: z.string(), size: z.number().nullable(), color: z.string().nullable() }),
slots: [],
description: "Icon display",
},
},
actions: standardActionDefinitions,
});
// Register only custom components (standard ones are built-in)
const { registry } = defineRegistry(catalog, {
components: {
Icon: ({ props }) => <Ionicons name={props.name} size={props.size ?? 24} />,
} as Components<typeof catalog>,
});
// Render
function App({ spec }) {
return (
<StateProvider initialState={{}}>
<VisibilityProvider>
<ActionProvider handlers={{}}>
<Renderer spec={spec} registry={registry} />
</ActionProvider>
</VisibilityProvider>
</StateProvider>
);
}ContainerRowColumnScrollContainerSafeAreaPressableSpacerDividerHeadingParagraphLabelImageAvatarBadgeChipButtonTextInputSwitchCheckboxSliderSearchBarSpinnerProgressBarCardListItemModalPressablesetState{
"type": "Pressable",
"props": {
"action": "setState",
"actionParams": { "path": "/activeTab", "value": "home" }
},
"children": ["home-icon", "home-label"]
}{ "$path": "/state/key" }{ "$cond": <condition>, "$then": <value>, "$else": <value> }{
"color": {
"$cond": { "eq": [{ "path": "/activeTab" }, "home"] },
"$then": "#007AFF",
"$else": "#8E8E93"
}
}setStateActionProvider{ "action": "setState", "actionParams": { "path": "/activeTab", "value": "home" } }| Provider | Purpose |
|---|---|
| Share state across components (JSON Pointer paths) |
| Handle actions dispatched from components |
| Enable conditional rendering based on state |
| Form field validation |
| Export | Purpose |
|---|---|
| Create a type-safe component registry from a catalog |
| Render a spec using a registry |
| React Native element tree schema |
| Catalog definitions for all standard components |
| Catalog definitions for standard actions |
| Pre-built component implementations |
| Create handlers for standard actions |
| Access data context |
| Get single value from data |
| Two-way data binding |
| Access actions context |
| Get a single action dispatch function |
| Stream specs from an API endpoint |