Render React Forms from JSON
Rendering forms is the core of FormEngine. The model is simple:- define a form in JSON
- choose a view that maps component types to React components
- render the schema with
FormViewer
The render model
FormEngine separates three concerns:- the schema describes the form
- the view maps schema component types to real React components
FormViewerrenders the schema through that view
Minimal example
This is the smallest useful render setup:App.tsx
viewtells FormEngine how to render component typesgetFormreturns the form JSONFormViewerrenders the result
Real working example from the FormEngine examples
The communityformdata example uses a real FormViewer setup like this:
From the formdata example
initialDataonFormDataChangeviewerRef- custom actions
What the form actually looks like
The booking-form example used across the real Next.js, Remix, and Formik samples renders like this:
What FormViewer does
FormViewer is the runtime component that turns your schema into a working form.
Its responsibilities include:
- rendering the component tree
- managing current form values
- running validation
- firing events and actions
- exposing runtime state through callbacks and refs
FormViewer.
The most important FormViewer props
| Prop | Required | Purpose |
|---|---|---|
view | yes | maps schema component types to actual React components |
getForm | yes | returns the form JSON string |
initialData | no | prefills the form with values |
onFormDataChange | no | lets your app react to live changes |
viewerRef | no | gives imperative access to the runtime |
actions | no | registers custom action handlers |
language | no | controls localization |
view and getForm are the essential pair.
What the JSON schema looks like
A form schema usually contains a rootScreen component and nested children:
contactForm.json
SampleForm.json used by the same example:
Real schema fragment from the formdata example
- inputs
- schema validation
- runtime actions
- a real submit button flow
What a view does
A view is the mapping layer between schema types likeRsInput and real React components from a UI library.
FormEngine ships with ready-made views for common stacks:
How data, validation, and events fit in
Rendering is only the first layer. Once the form is on screen:- form data tracks current values
- validation runs from the schema
- actions and events handle interaction logic
- conditional logic controls dynamic visibility
Common render patterns
Render from a local JSON file
This is the most common way to start:- create
myForm.json - import it into a component
- return it from
getForm
Render with initialData
Use this when a form is editing existing data:
Render with initial data
Render with runtime hooks
Use this when your app needs more control:Render with runtime access
When to use this page vs quickstart
Use the quickstart when you want the fastest path to a working form. Use this page when you want to understand the render model itself:- what
FormViewerdoes - how the JSON and view fit together
- how the runtime layers connect
FAQ
Do I need to store the form as a JSON string?
Do I need to store the form as a JSON string?
FormViewer expects getForm to return a string, so in practice you usually stringify a JSON object or import a JSON file directly.Can I switch UI libraries without rewriting the whole form?
Can I switch UI libraries without rewriting the whole form?
Often yes. That is one of the main benefits of separating the schema from the view layer.
What is the minimum required setup to render a form?
What is the minimum required setup to render a form?
A schema, a view, and a
FormViewer with getForm.Where should I go after this if I want interactive behavior?
Where should I go after this if I want interactive behavior?
Read form data, validation, actions and events, or conditional logic depending on which behavior you want to add next.
Next steps
Read form data
Learn how the runtime stores and exposes current values.
Read validation
Add schema-driven rules to the rendered form.
Read actions and events
Connect rendered components to submit and workflow logic.
Try it in the Online Builder
Build a form visually and inspect the exported JSON.