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 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>
);
}ContainerRowColumnScrollContainerSafeAreaPressableSpacerDividerHeadingParagraphLabelImageAvatarBadgeChipButtonTextInputSwitchCheckboxSliderSearchBarSpinnerProgressBarCardListItemModalvisible{ "$state": "/path" }{ "$state": "/path", "eq": value }{ "$state": "/path", "not": true }[ cond1, cond2 ]PressablesetState{
"type": "Pressable",
"props": {
"action": "setState",
"actionParams": { "statePath": "/activeTab", "value": "home" }
},
"children": ["home-icon", "home-label"]
}{ "$state": "/state/key" }{ "$bindState": "/path" }{ "$bindItem": "field" }{ "$cond": <condition>, "$then": <value>, "$else": <value> }{
"type": "TextInput",
"props": {
"value": { "$bindState": "/form/email" },
"placeholder": "Email"
}
}statePath{ "$bindState": "/path" }setStateActionProvider{ "action": "setState", "actionParams": { "statePath": "/activeTab", "value": "home" } }| Provider | Purpose |
|---|---|
| Share state across components (JSON Pointer paths). Accepts optional |
| Handle actions dispatched from components |
| Enable conditional rendering based on state |
| Form field validation |
StateStoreStateProviderJSONUIProvidercreateRendererimport { createStateStore, type StateStore } from "@json-render/react-native";
const store = createStateStore({ count: 0 });
<StateProvider store={store}>{children}</StateProvider>
store.set("/count", 1); // React re-renders automaticallystoreinitialStateonStateChange| 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 state context |
| Get single value from state |
| Two-way state binding via |
| (deprecated) Legacy two-way binding by path |
| Access actions context |
| Get a single action dispatch function |
| Stream specs from an API endpoint |
| Create a framework-agnostic in-memory |
| Interface for plugging in external state management |