redux-form
A Higher Order Component using react-redux to keep form state in a Redux store
Top Related Projects
Build forms in React, without the tears 😭
📋 React Hooks for form state management and validation (Web + React Native)
🏁 High performance subscription-based form state management for React
🤖 Headless, performant, and type-safe form state management for TS/JS, React, Vue, Angular, Solid, and Lit.
Performance-focused API for React forms 🚀
Quick Overview
Redux Form is a popular library for managing form state in Redux applications. It provides a way to connect form inputs to Redux store, handle form validation, and manage form submission, making it easier to create complex forms in React applications with Redux.
Pros
- Seamless integration with Redux, allowing form state to be part of the global application state
- Built-in support for form validation, including synchronous and asynchronous validation
- Provides performance optimizations by only updating changed fields
- Extensive documentation and community support
Cons
- Can be overkill for simple forms, adding unnecessary complexity
- Learning curve for developers new to Redux or complex form management
- Performance issues can arise with large forms or frequent updates
- Some users report difficulties with TypeScript integration
Code Examples
- Basic form setup:
import { reduxForm, Field } from 'redux-form';
const SimpleForm = ({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field name="username" component="input" type="text" />
<Field name="password" component="input" type="password" />
<button type="submit">Submit</button>
</form>
);
export default reduxForm({ form: 'simple' })(SimpleForm);
- Form with validation:
const validate = values => {
const errors = {};
if (!values.username) {
errors.username = 'Required';
}
if (!values.password) {
errors.password = 'Required';
}
return errors;
};
const SimpleForm = ({ handleSubmit, pristine, submitting }) => (
<form onSubmit={handleSubmit}>
<Field name="username" component={renderField} type="text" />
<Field name="password" component={renderField} type="password" />
<button type="submit" disabled={pristine || submitting}>Submit</button>
</form>
);
export default reduxForm({
form: 'simple',
validate
})(SimpleForm);
- Connecting form to Redux store:
import { connect } from 'react-redux';
import { reduxForm } from 'redux-form';
const mapStateToProps = state => ({
initialValues: state.user // Pre-populate form with user data
});
const SimpleForm = reduxForm({ form: 'simple' })(YourFormComponent);
export default connect(mapStateToProps)(SimpleForm);
Getting Started
-
Install Redux Form:
npm install redux-form
-
Add Redux Form reducer to your root reducer:
import { reducer as formReducer } from 'redux-form'; const rootReducer = combineReducers({ // other reducers form: formReducer });
-
Create a form component using Redux Form:
import { reduxForm, Field } from 'redux-form'; const MyForm = ({ handleSubmit }) => ( <form onSubmit={handleSubmit}> <Field name="firstName" component="input" type="text" /> <button type="submit">Submit</button> </form> ); export default reduxForm({ form: 'myForm' })(MyForm);
-
Use the form in your React component:
const MyComponent = () => { const onSubmit = values => console.log(values); return <MyForm onSubmit={onSubmit} />; };
Competitor Comparisons
Build forms in React, without the tears 😭
Pros of Formik
- Lightweight and less boilerplate code
- Works with any UI framework or form library
- Built-in Yup integration for easy schema validation
Cons of Formik
- Less powerful for complex form scenarios
- Lacks some advanced features like asynchronous validation
Code Comparison
Redux Form:
import { reduxForm, Field } from 'redux-form';
const MyForm = ({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field name="username" component="input" type="text" />
<button type="submit">Submit</button>
</form>
);
export default reduxForm({ form: 'myForm' })(MyForm);
Formik:
import { Formik, Form, Field } from 'formik';
const MyForm = () => (
<Formik initialValues={{ username: '' }} onSubmit={handleSubmit}>
<Form>
<Field name="username" type="text" />
<button type="submit">Submit</button>
</Form>
</Formik>
);
export default MyForm;
The code comparison shows that Formik requires less setup and boilerplate compared to Redux Form. Formik's API is more straightforward and doesn't require connecting to Redux, making it easier to use in smaller projects or those not using Redux for state management.
📋 React Hooks for form state management and validation (Web + React Native)
Pros of react-hook-form
- Lightweight and performant, with minimal re-renders
- Easy to use with React Hooks, reducing boilerplate code
- Built-in validation and error handling
Cons of react-hook-form
- Less integration with Redux ecosystem
- May require additional setup for complex form scenarios
- Learning curve for developers familiar with Redux-Form
Code Comparison
redux-form:
import { Field, reduxForm } from 'redux-form';
const MyForm = ({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field name="username" component="input" type="text" />
<button type="submit">Submit</button>
</form>
);
export default reduxForm({ form: 'myForm' })(MyForm);
react-hook-form:
import { useForm } from 'react-hook-form';
const MyForm = () => {
const { register, handleSubmit } = useForm();
const onSubmit = data => console.log(data);
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input {...register("username")} />
<button type="submit">Submit</button>
</form>
);
};
react-hook-form offers a more concise and hook-based approach, while redux-form integrates tightly with Redux state management. The choice between them depends on project requirements and developer preferences.
🏁 High performance subscription-based form state management for React
Pros of react-final-form
- Lighter weight and more performant, especially for large forms
- No Redux dependency, making it more flexible for different state management solutions
- Simpler API and easier to get started with
Cons of react-final-form
- Less mature ecosystem and fewer third-party extensions
- May require more manual work for complex form scenarios
- Smaller community and potentially slower issue resolution
Code Comparison
redux-form:
import { reduxForm, Field } from 'redux-form'
const MyForm = ({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field name="firstName" component="input" type="text" />
<button type="submit">Submit</button>
</form>
)
export default reduxForm({ form: 'myForm' })(MyForm)
react-final-form:
import { Form, Field } from 'react-final-form'
const MyForm = () => (
<Form
onSubmit={onSubmit}
render={({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field name="firstName" component="input" type="text" />
<button type="submit">Submit</button>
</form>
)}
/>
)
Both libraries provide similar functionality for form management in React applications. redux-form is more established and integrates well with Redux-based apps, while react-final-form offers a lighter, more flexible solution that can be used in various state management contexts.
🤖 Headless, performant, and type-safe form state management for TS/JS, React, Vue, Angular, Solid, and Lit.
Pros of TanStack Form
- Framework-agnostic, supporting React, Vue, Svelte, and more
- Lightweight and performant, with minimal re-renders
- Flexible API with powerful validation and error handling
Cons of TanStack Form
- Steeper learning curve due to its more abstract approach
- Less opinionated, requiring more setup for complex forms
- Smaller community and ecosystem compared to Redux Form
Code Comparison
Redux Form:
import { reduxForm, Field } from 'redux-form';
const MyForm = ({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field name="username" component="input" type="text" />
<button type="submit">Submit</button>
</form>
);
export default reduxForm({ form: 'myForm' })(MyForm);
TanStack Form:
import { useForm } from '@tanstack/react-form';
const MyForm = () => {
const form = useForm({
defaultValues: { username: '' },
onSubmit: (values) => console.log(values),
});
return (
<form.Provider>
<form onSubmit={form.handleSubmit}>
<input {...form.register('username')} />
<button type="submit">Submit</button>
</form>
</form.Provider>
);
};
TanStack Form offers a more flexible and framework-agnostic approach, while Redux Form provides a more opinionated and Redux-integrated solution. The choice between them depends on project requirements, preferred ecosystem, and development style.
Performance-focused API for React forms 🚀
Pros of Unform
- Lightweight and performant, with minimal re-renders
- Framework-agnostic, supporting React, React Native, and Vue.js
- Easy integration with various UI libraries and custom components
Cons of Unform
- Less mature ecosystem compared to Redux Form
- Fewer built-in validations and advanced features
- Steeper learning curve for developers familiar with Redux-based form management
Code Comparison
Redux Form:
import { reduxForm, Field } from 'redux-form';
const MyForm = ({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field name="username" component="input" type="text" />
<button type="submit">Submit</button>
</form>
);
export default reduxForm({ form: 'myForm' })(MyForm);
Unform:
import { Form, Input } from '@unform/web';
const MyForm = () => (
<Form onSubmit={handleSubmit}>
<Input name="username" type="text" />
<button type="submit">Submit</button>
</Form>
);
export default MyForm;
The code comparison shows that Unform requires less boilerplate and doesn't rely on Redux, making it more straightforward for simple forms. However, Redux Form's integration with Redux can be beneficial for complex applications with centralized state management.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
redux-form
You build great forms, but do you know HOW users use your forms? Find out with Form Nerd! Professional analytics from the creator of Redux Form.
redux-form
works with React Redux to
enable an html form in React to use
Redux to store all of its state.
ð°Psst!! Do you know React and Redux? Sign up with Triplebyte to get offers from top tech companies! ð°
â ï¸ ATTENTION â ï¸
If you're just getting started with your application and are looking for a form solution, the general consensus of the community is that you should not put your form state in Redux. The author of Redux Form took all of the lessons he learned about form use cases from maintaining Redux Form and built ð React Final Form, which he recommends you use if you are just starting your project. It's also pretty easy to migrate to from Redux Form, because the <Field>
component APIs are so similar. Here is a blog post where he explains his reasoning, or there are two talks if you prefer video. Formik is also a nice solution.
The only good reason, in the author's view, to use Redux Form in your application is if you need really tight coupling of your form data with Redux, specifically if you need to subscribe to it and modify it from parts of your application far from your form component, e.g. on another route. If you don't have that requirement, use ð React Final Form.
Installation
npm install --save redux-form
Documentation
ð Code Sandboxes ð
You can play around with redux-form
in these sandbox versions of the Examples.
- Simple Form
- Synchronous Validation
- Field-Level Validation
- Submit Validation
- Asynchronous Blur Validation
- Initializing From State
- Field Arrays
- Remote Submit
- Normalizing
- Immutable JS
- Selecting Form Values
- Wizard Form
Videos
![]() |
---|
A Practical Guide to Redux Form â React Alicante 2017 |
![]() |
---|
Abstracting Form State with Redux Form â JS Channel 2016 |
Contributors
This project exists thanks to all the people who contribute.
Backers
Thank you to all our backers! ð [Become a backer]
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

Top Related Projects
Build forms in React, without the tears 😭
📋 React Hooks for form state management and validation (Web + React Native)
🏁 High performance subscription-based form state management for React
🤖 Headless, performant, and type-safe form state management for TS/JS, React, Vue, Angular, Solid, and Lit.
Performance-focused API for React forms 🚀
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot