user-auth-pkg
Version:
A **highly customizable** and **reusable login form component** built with **React Hook Form**, **Yup**, and **Material UI**, supporting **image uploads**, **file inputs**, **CAPTCHA validation**, and flexible UI overrides.
86 lines (65 loc) โข 2.85 kB
Markdown
A **highly customizable** and **reusable login form component** built with **React Hook Form**, **Yup**, and **Material UI**, supporting **image uploads**, **file inputs**, **CAPTCHA validation**, and flexible UI overrides.
---
- ๐ **Dynamic field rendering** via configuration (custom field creation and dynamic fields)
- ๐ **Validation** using **Yup** for strong form input validation
- ๐ง **Smart form handling** with **react-hook-form** for seamless form processing
- ๐ผ๏ธ **Built-in support for image uploads** for profile pictures or other media
- ๐ **File input support** for document uploads
- ๐ **Google reCAPTCHA integration** (v2) for **CAPTCHA validation** to prevent bots
- ๐จ **Customizable components** for form inputs and buttons (UI flexibility)
- ๐ก **Axios integration** for form submission to a backend or API
---
## ๐ก Example Usage
Below is an example of how to use the `AuthRegisterForm` component for a registration form:
````jsx
import { Stack, Grid } from '@mui/material';
import { useRouter } from 'next/router';
import RegisterForm from 'user-auth-pkg';
import RegisterFormConfig from './RegisterFormConfig';
import { CustomInput, CustomButton, CustomImageInput, CustomSelect } from './CustomComponents';
export default function AuthRegisterForm() {
const router = useRouter();
const handleSuccess = (response) => {
console.log('โ
Registration response:', response);
router.push({
pathname: '/verify-code',
});
};
const handleError = (err) => {
console.error('โ Registration Error:', err);
};
return (
<Stack spacing={3}>
<RegisterForm
config={RegisterFormConfig().fields}
onSuccess={handleSuccess}
onError={handleError}
buttonText="Sign Up"
isLoadingText="Sending Request..."
textFieldComponent={CustomInput}
imageFieldComponent={CustomImageInput}
buttonComponent={CustomButton}
selectFieldComponent={CustomSelect}
axiosConfig={{
url: 'your-api-url',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
}}
enableCaptcha
captchaSiteKey="your-captcha-site-key"
/>
</Stack>
);
}
Check out the source code and contribute to the project on [GitHub](https://github.com/Abdul-rehman-pwr/user-auth-pkg.git).
---
To install the package and required dependencies, run the following commands:
```bash
npm install user-auth-pkg
npm install react react-dom react-hook-form yup axios react-google-recaptcha
````