12k

@json-render/react-native

React Native renderer with standard components, providers, and hooks.

Standard Components#

Layout#

ComponentPropsDescription
Containerpadding, background, borderRadius, borderColor, flexBasic wrapper with styling
Rowgap, align, justify, flex, wrapHorizontal flex layout
Columngap, align, justify, flexVertical flex layout
ScrollContainerdirectionScrollable area (vertical or horizontal)
SafeAreaedgesSafe area insets for notch/home indicator
Pressableaction, actionParamsTouchable wrapper that triggers actions
Spacersize, flexFixed or flexible spacing
Dividercolor, thicknessThin line separator

Content#

ComponentPropsDescription
Headingtext, level, align, colorHeading text (levels 1-6)
Paragraphtext, align, colorBody text
Labeltext, color, boldSmall label text
Imageuri, width, height, resizeMode, borderRadiusImage display
Avataruri, size, fallbackCircular avatar
Badgelabel, color, textColorStatus badge
Chiplabel, selected, colorTag/chip

Input#

ComponentPropsDescription
Buttonlabel, variant, size, disabled, action, actionParamsPressable button
TextInputplaceholder, value (use $bindState), secure, keyboardType, multilineText input field
Switchchecked (use $bindState), labelToggle switch
Checkboxchecked (use $bindState), labelCheckbox with label
Slidervalue (use $bindState), min, max, stepRange slider
SearchBarplaceholder, value (use $bindState)Search input

Feedback#

ComponentPropsDescription
Spinnersize, colorLoading indicator
ProgressBarprogress, color, trackColorProgress indicator

Composite#

ComponentPropsDescription
Cardtitle, subtitle, paddingCard container
ListItemtitle, subtitle, leading, trailing, action, actionParamsList row
Modalvisible, titleBottom sheet modal

Providers#

StateProvider#

<StateProvider initialState={object} onStateChange={fn}>
  {children}
</StateProvider>
PropTypeDescription
storeStateStoreExternal store (controlled mode). When provided, initialState and onStateChange are ignored.
initialStateRecord<string, unknown>Initial state model (uncontrolled mode).
onStateChange(changes: Array<{ path: string; value: unknown }>) => voidCallback when state changes (uncontrolled mode). Called once per set or update with all changed entries.

External Store (Controlled Mode)

Pass a StateStore to bypass the internal state and wire json-render to any state management library:

import { createStateStore, type StateStore } from "@json-render/react-native";

const store = createStateStore({ count: 0 });

<StateProvider store={store}>
  {children}
</StateProvider>

// Mutate from anywhere — components re-render automatically:
store.set("/count", 1);

The store prop is also available on JSONUIProvider and createRenderer.

ActionProvider#

<ActionProvider handlers={Record<string, ActionHandler>}>
  {children}
</ActionProvider>

VisibilityProvider#

<VisibilityProvider>
  {children}
</VisibilityProvider>

Conditions in specs use the VisibilityCondition format with $state paths (e.g. { "$state": "/path" }, { "$state": "/path", "eq": value }). See visibility for the full syntax.

ValidationProvider#

<ValidationProvider>
  {children}
</ValidationProvider>

defineRegistry#

Create a type-safe component registry. Standard components are built-in; only register custom components.

import { defineRegistry, type Components } from '@json-render/react-native';

const { registry } = defineRegistry(catalog, {
  components: {
    Icon: ({ props }) => <Ionicons name={props.name} size={props.size ?? 24} />,
  } as Components<typeof catalog>,
});

Hooks#

useUIStream#

const {
  spec,         // Spec | null - current UI state
  isStreaming,  // boolean - true while streaming
  error,        // Error | null
  send,         // (prompt: string) => Promise<void>
  clear,        // () => void - reset spec and error
} = useUIStream({
  api: string,
  onComplete?: (spec: Spec) => void,
  onError?: (error: Error) => void,
});

useStateStore#

const { state, get, set, update } = useStateStore();

useStateValue#

const value = useStateValue(path: string);

useStateBinding (deprecated)#

Deprecated. Use useBoundProp with $bindState expressions instead.

const [value, setValue] = useStateBinding(path: string);

useActions#

const { execute } = useActions();

useIsVisible#

const isVisible = useIsVisible(condition?: VisibilityCondition);

Catalog Exports#

import { standardComponentDefinitions, standardActionDefinitions } from "@json-render/react-native/catalog";
import { schema } from "@json-render/react-native/schema";
ExportPurpose
standardComponentDefinitionsCatalog definitions for all 25+ standard components
standardActionDefinitionsCatalog definitions for standard actions (setState, navigate)
schemaReact Native element tree schema