Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/basedhound/formik-yup_next

React form with robust validation using Formik for managing form state and Yup for schema-based validation. It showcases efficient form handling, including validation and submission.
https://github.com/basedhound/formik-yup_next

form formik formik-yup nextjs nextjs13 react react18 tailwind yup yup-schema yup-validation

Last synced: 4 days ago
JSON representation

React form with robust validation using Formik for managing form state and Yup for schema-based validation. It showcases efficient form handling, including validation and submission.

Awesome Lists containing this project

README

        



Project Banner

React Form: Formik + Yup


##
πŸ“‹ Table of Contents

- ✨ [Introduction](#introduction)
- βš™οΈ [Tech Stack](#tech-stack)
- πŸ“ [Features](#features)
- πŸš€ [Quick Start](#quick-start)

##
✨ Introduction

**[EN]** React form with robust validation using Formik for managing form state and Yup for schema-based validation. It showcases efficient form handling, including validation and submission, highlighting best practices for creating reliable and user-friendly forms in a React application.

**[FR]** Formulaire React avec une validation robuste utilisant Formik pour la gestion du state du formulaire et Yup pour la validation basΓ©e sur un schΓ©ma. Bonne pratique assurant une gestion efficace des formulaires dans le cas d'une application React.

##
βš™οΈ Tech Stack

- [**Formik**](https://formik.org/docs/overview) is a popular React library for building forms, providing an efficient way to manage form state, handle submissions, and perform validation. Formik's intuitive API and component-based architecture simplify form creation, making it easier to create and maintain complex forms in React applications.

- [**Yup**](https://www.npmjs.com/package/yup/v/1.0.0-alpha.3) is a JavaScript schema builder for value parsing and validation, widely used in conjunction with form libraries like Formik. It allows developers to define validation rules and schemas in a declarative manner, ensuring data integrity and simplifying the validation logic in forms.

- [**React**](https://react.dev/reference/react) is a popular JavaScript library for building user interfaces, particularly single-page applications where data changes over time. React's component-based architecture allows developers to create reusable UI components, making development more efficient and the codebase easier to maintain.

- [**Next.js**](https://nextjs.org/docs) is a React framework known for its server-side rendering (SSR) and static site generation (SSG) capabilities, enhancing performance and SEO for web applications. It offers features like automatic code splitting, API routes for server-side logic, and a plugin system for extensibility.

- [**Tailwind**](https://v2.tailwindcss.com/docs) is a utility-first CSS framework that speeds up UI development by providing a set of pre-built utility classes. It allows developers to quickly build custom designs without writing traditional CSS, promoting rapid prototyping and design consistency.

##
πŸ“ Features

### Formik

πŸ‘‰ **Form State Management**: Formik simplifies the management of form state in React applications, handling input values, errors, and submission status.

πŸ‘‰ **Form Validation**: It provides built-in utilities for validating form inputs and displaying error messages based on validation rules.

πŸ‘‰ **Form Submission Handling**: Formik manages form submissions, including asynchronous submissions and handling form reset actions.

πŸ‘‰ **Field-Level Validation**: It supports field-level validation, allowing developers to define validation rules specific to each form field.

πŸ‘‰ **Integration with React Ecosystem**: Formik seamlessly integrates with other React libraries and frameworks, enhancing developer productivity and maintaining compatibility.

### Yup

πŸ‘‰ **Schema-Based Validation**: Yup enables developers to define validation schemas using a fluent API, specifying data types, required fields, and custom validation rules.

πŸ‘‰ **Declarative Validation Rules**: It allows for declarative validation rules, making it easy to define complex validation logic in a readable and maintainable way.

πŸ‘‰ **Asynchronous Validation**: Yup supports asynchronous validation, enabling validation rules that depend on server-side data or external APIs.

πŸ‘‰ **Custom Error Messages**: Developers can customize error messages based on validation failures, providing clear feedback to users.

πŸ‘‰ **Integration with Form Libraries**: Yup integrates seamlessly with form libraries like Formik, providing robust validation capabilities for forms built with these libraries.

##
πŸš€ Quick Start

Follow these steps to set up the project locally on your machine.


**Prerequisites**

Make sure you have the following installed on your machine:

- [Git](https://git-scm.com/)
- [Node.js](https://nodejs.org/en)
- [npm](https://www.npmjs.com/) (Node Package Manager)


**Cloning the Repository**

```bash
git clone {git remote URL}
```


**Installation**

Let's install the project dependencies, from your terminal, run:

```bash
npm install
# or
yarn install
```


**Running the Project**

Installation will take a minute or two, but once that's done, you should be able to run the following command:

```bash
npm run dev
# or
yarn dev
```

Open [`http://localhost:3000`](http://localhost:3000) in your browser to view the project.