Automagically manage React forms state with auto-validation using MobX
Clone or download
Latest commit 37afbb1 Jan 18, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
src style: rename hasBlurred to blurred Jan 18, 2019
tests fix: #468 #453 Jan 10, 2019
.babelrc chore: #88 Oct 16, 2016
.eslintrc.json fix: #364 #471 Jan 16, 2019
.gitignore feat: mobx5 support + fix: #432 #415 #355 #347 #425 Jul 20, 2018
.travis.yml feat: mobx5 support Jul 20, 2018 feat: mobx5 support Jul 20, 2018 nested-fields Oct 15, 2016
LICENSE docs: Oct 16, 2016 Activating Open Collective (#418) Aug 20, 2018
demo fix: #320 (rollback #310) Sep 3, 2017
package.json fix: #364 #471 Jan 16, 2019
webpack.config.babel.js feat: reimplemented add() method + added struct prop Apr 17, 2018
yarn.lock fix: #477 Jan 18, 2019

MobX React Form

Automagically manage React forms state and automatic validation with MobX.

Travis Build Codecov Coverage npm node GitHub license Downloads Downloads Backers on Open Collective Sponsors on Open Collective



  • Automatic Reactive Form State Management with MobX Magic.
  • Automatic Reactive Validation & Error Messages.
  • Validation Plugins & Multiple Validation Styles.
  • Nested Fields (w/ Serialization & Validation).
  • Nested Forms (w/ Nested Submission & Validation Hooks).
  • Dynamically Add/Del Nested Fields.
  • Support for Sync & Async Validation functions (w/ Promises).
  • Fields Props Bindings for custom Components.
  • Support for Material UI, React Widgets, React Select & more.
  • Dedicated DevTools Package.

Edit form-quickstart


Live Demo

Demo Code


Automagically manage React forms state and automatic validation with MobX

Quick Start

npm install --save mobx-react-form

Choose and Setup a Validation Plugin

See Validation Plugins & Modes and Supported Validation Packages for more info.

Below we are creating a plugins object using the validatorjs package to enable DVR functionalities (Declarative Validation Rules).

import validatorjs from 'validatorjs';

const plugins = { dvr: validatorjs };

Define the Form Fields

Define the fields as a collection with a rules property for the validation.

const fields = [{
  name: 'email',
  label: 'Email',
  placeholder: 'Insert Email',
  rules: 'required|email|string|between:5,25',
}, {
  name: 'password',
  label: 'Password',
  placeholder: 'Insert Password',
  rules: 'required|string|between:5,25',
}, {
  name: 'passwordConfirm',
  label: 'Password Confirmation',
  placeholder: 'Confirm Password',
  rules: 'required|string|same:password',

You can also define fields as an object.

Define the Validation Hooks

const hooks = {
  onSuccess(form) {
    alert('Form is valid! Send the request here.');
    // get field values
    console.log('Form Values!', form.values());
  onError(form) {
    alert('Form has errors!');
    // get all form errors
    console.log('All form errors', form.errors());

Initialize the Form

Simply pass the fields, plugins and hooks objects to the constructor

import MobxReactForm from 'mobx-react-form';

const form = new MobxReactForm({ fields }, { plugins, hooks });

Pass the form to a react component

The package provide some built-in and ready to use Event Handlers:

onSubmit(e), onClear(e), onReset(e) & more...

import React from 'react';
import { observer } from 'mobx-react';

export default observer(({ form }) => (
  <form onSubmit={form.onSubmit}>
    <label htmlFor={form.$('email').id}>
    <input {...form.$('email').bind()} />

    {/* ... other inputs ... */}

    <button type="submit" onClick={form.onSubmit}>Submit</button>
    <button type="button" onClick={form.onClear}>Clear</button>
    <button type="button" onClick={form.onReset}>Reset</button>


Other Field Props are available. See the docs for more details.

Extending the Form class

See how to implement the same configuration of this quickstart extending the Form class


If you want to contribute to the development, do not hesitate to fork the repo and send pull requests.

And don't forget to star the repo, I will ensure more frequent updates! Thanks!


This project exists thanks to all the people who contribute.


Thank you to all our backers! 🙏 [Become a backer]


Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]