-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learn React with TypeScript
By :

Forms are extremely common in apps, so it’s essential to be able to implement them efficiently. In this chapter, we’ll build a contact form that you often see on company websites in Next.js. It will contain a handful of fields and some validation logic.
We will start with a basic form implementation using native browser capabilities. We’ll revise the form submission to use a Route Handler and then a React Server Action introducing server validation. We’ll then implement a submission indicator and better error handling using React form status and action state. We’ll use a popular library called React Hook Form to add client-side validation. Lastly, we’ll implement optimistic updates for an even better user experience.
By the end of this chapter, you’ll be able to build user-friendly and robust forms in React.
We’ll cover the following topics: