Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react

> 前端框架
Open source

JSON powered forms for React.js

250.8K stars0 likes1 views
WebsiteGitHub

About

JSON powered forms for React.js

@formio/react

A React library for rendering out forms based on the Form.io platform.

Official Documentation

For the latest documentation, release information, and guides, always refer to the official Form.io Help Documentation available here:

https://help.form.io

Install

npm

bash
npm install @formio/react --save
npm install @formio/js --save

yarn

bash
yarn add @formio/react @formio/js

Usage with Vite (Note: When using frameworks like Next.js or Create React App, no extra Vite configuration is necessary)

When using @formio/react in a project built with Vite (especially for React 18 and 19), make sure you install the @vitejs/plugin-react package and configure it in your vite.config.js file.

Install Vite React Plugin

bash
yarn add --dev @vitejs/plugin-react

In your vite.config.js, add the React plugin:

bash
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
});

Hooks

useFormioContext

A hook to supply global Formio contextual values to your React components. Components that call useFormioContext must be children of a `` component.

Return Value

useFormioContext returns an object with the following parameters:

Name Type Description
Formio typeof Formio The global Formio object. Useful for various static methods as well as SDK functions that are exposed when the new operator is used.
baseUrl string The base url for a Form.io server.
projectUrl string The base url for a Form.io enterprise project.
logout () => void A convenience method to logout of a Form.io session by invalidating the token and removing it from local storage.
token string The Form.io JWT-token (if the user is authenticated).
isAuthenticated boolean A convenience value that is toggled when logging in or out of a Form.io session.

Examples

Use the authentication context provided by useFormioContext to evaluate the Form.io authentication of a user:

typescript
import { createRoot } from 'react-dom/client';
import { useFormioContext, FormGrid, FormioProvider } from '@formio/react';

const App = () => {
	const { isAuthenticated } = useFormioContext();

	return isAuthenticated ? (
		
			
				 setLocation(`/form/${id}`)}
				/>
			
			
				 setLocation(`/resource/${id}`)}
				/>
			
		
	) : (
		
	);
};

const domNode = document.getElementById('root');
const root = createRoot(domNode);
root.render(
	
		
	,
);

Use the Form.io SDK to interact with a Form.io server:

…

Components

FormioProvider

A React context provider component that is required when using some hooks and components from this library.

Props

Name Type Description
Formio object The Formio object to be used.
baseUrl string The base url of a Form.io server.
projectUrl string The url of a Form.io enterprise project.

Examples

Render a simple form from your self hosted Form.io deployment:

javascript
import { createRoot } from 'react-dom/client';
import { Form, FormioProvider } from '@formio/react';

const domNode = document.getElementById('root');
const root = createRoot(domNode);

root.render(
  
    
  
);

Extend the Formio object to use external modules:

javascript
import { createRoot } from 'react-dom/client';
import { Form, FormioProvider } from '@formio/react';
import { Formio } from '@formio/js';
import premium from '@formio/premium';

const domNode = document.getElementById('root');
const root = createRoot(domNode);

Formio.use(premium);
root.render(
  
    
  
);

Form

A React component wrapper around a Form.io form. Able to take a JSON form definition or a Form.io form URL and render the form in your React application.

Props

Name Type Default Description
src Webform | string The JSON form definition or the source URL. If a URL, commonly from a form.io server.
url string The url of the form definition. Used in conjunction with a JSON form definition passed to src, this is used for file upload, OAuth, and other components or actions that need to know the URL of the Form.io form for further processing. The form will not be loaded from this url and the submission will not be saved here either.
submission JSON Submission data to fill the form. You can either load a previous submission or create a submission with some pre-filled data. If you do not provide a submissions the form will initialize an empty submission using default values from the form.
options FormOptions The form options. See here for more details.
onFormReady (instance: Webform) => void A callback function that gets called when the form has rendered. It is useful for accessing the underlying @formio/js Webform instance.
onSubmit (submission: JSON, saved?: boolean) => void A callback function that gets called when the submission has started. If src is not a Form.io server URL, this will be the final submit event.
onCancelSubmit () => void A callback function that gets called when the submission has been canceled.
onSubmitDone (submission: JSON) => void A callback function that gets called when the submission has successfully been made to the server. This will only fire if src is set to a Form.io server URL.
onChange (value: any, flags: any, modified: any) => void A callback function that gets called when a value in the submission has changed.
onComponentChange (changed: { instance: Webform; component: Component; value: any; flags: any}) => void A callback function that gets called when a specific component changes.
onError (error: EventError | false) => void A callback function that gets called when an error occurs during submission (e.g. a validation error).
onRender (param: any) => void A callback function that gets called when the form is finished rendering. param will depend on the form and display type.
onCustomEvent (event: { type: string; component: Component; data: JSON; event?: Event; }) => void A callback function that is triggered from a button component configured with "Event" type.
onPrevPage (page: number, submission: JSON) => void A callback function for Wizard forms that gets called when the "Previous" button is pressed.

Issues· 39 open

View all issuesOpen on GitHub
  • #647

    [BUG] Signature component fires change event with `modified = false` on user input

    Updated Jun 26, 2026
  • #590

    Two loading spinners are displayed

    help wantedUpdated Feb 11, 2026
  • #632

    onChange `modified` property remains false when file component is updated

    Updated Jan 28, 2026
  • #630

    FormBuilder with OnChange broke textarea

    Updated Jan 14, 2026
  • #631

    FormBuilder onChange callback not triggered when options prop is provided

    Updated Dec 29, 2025
  • #626

    Custom component fails after upgrading @formio/[email protected]

    Updated Nov 19, 2025
  • #624

    Branch Reorganization Update – 2 September 2025

    Updated Sep 3, 2025
  • #622

    I dont find any information for options to FormBuilder component

    Updated Aug 21, 2025
  • #579

    Customize Drag and Drop Zone

    Updated Jul 22, 2025
  • #616

    Changing the display from form to wizard to form and then removing the panel breaks the builder

    Updated Jul 8, 2025

> Tags

TypeScriptformioformsjsonreactjs

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 30, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架