Gathering detailed insights and metrics for @hookform/error-message
Gathering detailed insights and metrics for @hookform/error-message
Gathering detailed insights and metrics for @hookform/error-message
Gathering detailed insights and metrics for @hookform/error-message
npm install @hookform/error-message
Typescript
Module System
Node Version
NPM Version
91.5
Supply Chain
89
Quality
79.6
Maintenance
100
Vulnerability
100
License
TypeScript (92.52%)
JavaScript (6.93%)
Shell (0.56%)
Total Downloads
48,796,651
Last Day
18,110
Last Week
492,980
Last Month
1,985,745
Last Year
20,056,065
MIT License
353 Stars
116 Commits
17 Forks
3 Watchers
15 Branches
10 Contributors
Updated on Jul 10, 2025
Latest Version
2.0.1
Package Id
@hookform/error-message@2.0.1
Unpacked Size
20.83 kB
Size
5.62 kB
File Count
14
NPM Version
8.12.1
Node Version
18.5.0
Cumulative downloads
Total Downloads
Last Day
-6.5%
18,110
Compared to previous day
Last Week
1.9%
492,980
Compared to previous week
Last Month
-1.6%
1,985,745
Compared to previous month
Last Year
43.1%
20,056,065
Compared to previous year
3
22
Performant, flexible and extensible forms with easy to use validation.
A simple component to render associated input's error message.
$ npm install @hookform/error-message
1import React from 'react'; 2import { useForm } from 'react-hook-form'; 3import { ErrorMessage } from '@hookform/error-message'; 4 5export default function App() { 6 const { register, formState: { errors }, handleSubmit } = useForm(); 7 const onSubmit = (data) => console.log(data); 8 9 return ( 10 <form onSubmit={handleSubmit(onSubmit)}> 11 <input 12 name="singleErrorInput" 13 ref={register({ required: 'This is required.' })} 14 /> 15 <ErrorMessage errors={errors} name="singleErrorInput" /> 16 17 <ErrorMessage 18 errors={errors} 19 name="singleErrorInput" 20 render={({ message }) => <p>{message}</p>} 21 /> 22 23 <input name="name" ref={register({ required: true })} /> 24 <ErrorMessage errors={errors} name="name" message="This is required" /> 25 26 <input type="submit" /> 27 </form> 28 ); 29}
1import React from 'react'; 2import { useForm } from 'react-hook-form'; 3import { ErrorMessage } from '@hookform/error-message'; 4 5export default function App() { 6 const { register, formState: { errors }, handleSubmit } = useForm({ 7 criteriaMode: 'all', 8 }); 9 const onSubmit = (data) => console.log(data); 10 11 return ( 12 <form onSubmit={handleSubmit(onSubmit)}> 13 <input 14 name="multipleErrorInput" 15 ref={register({ 16 required: 'This is required.', 17 pattern: { 18 value: /d+/, 19 message: 'This input is number only.', 20 }, 21 maxLength: { 22 value: 10, 23 message: 'This input exceed maxLength.', 24 }, 25 })} 26 /> 27 <ErrorMessage 28 errors={errors} 29 name="multipleErrorInput" 30 render={({ messages }) => 31 messages && 32 Object.entries(messages).map(([type, message]) => ( 33 <p key={type}>{message}</p> 34 )) 35 } 36 /> 37 38 <input type="submit" /> 39 </form> 40 ); 41}
Prop | Type | Required | Description |
---|---|---|---|
name | string | ✓ | Associated field name. |
errors | object | errors object from React Hook Form. It's optional if you are using FormProvider . | |
message | string | React.ReactElement | inline error message. | |
as | string | React.ReactElement | React.ComponentType | Wrapper component or HTML tag. eg: as="p" , as={<p />} or as={CustomComponent} . This prop is incompatible with prop render and will take precedence over it. | |
render | Function | This is a render prop for rendering error message or messages. Note: you need to set criteriaMode to all for using messages. |
Thank goes to all our backers! [Become a backer].
Thanks goes to these wonderful people. [Become a contributor].
No vulnerabilities found.