A comprehensive form application built with React, TypeScript, and Vite, demonstrating advanced form handling with validation and data persistence.
- Advanced Form Management: Built with React Hook Form for efficient form state management
- Schema Validation: Uses Zod for robust client-side validation
- TypeScript: Fully typed with TypeScript for better development experience
- Real-time Validation: Form validation occurs as you type
- Data Persistence: Stores form submissions in RushDB
- Responsive Design: Clean, modern UI that works on all devices
- Comprehensive Form Fields: Includes various input types and complex nested data structures
The application includes a multi-section form with:
- First Name, Last Name
- Email, Phone Number
- Date of Birth
- Street Address, City, State
- ZIP Code, Country
- Company, Position
- Experience Level (Entry to Executive)
- Salary, Skills (dynamic array)
- Newsletter subscription
- Notifications settings
- Public profile visibility
- Data sharing preferences
- Bio (up to 500 characters)
- Website, LinkedIn, GitHub URLs
- Frontend Framework: React 19.1.0
- Build Tool: Vite 7.0.0
- Language: TypeScript 5.8.3
- Form Management: React Hook Form 7.58.1
- Validation: Zod 3.25.67 with @hookform/resolvers
- Database: RushDB JavaScript SDK 1.7.0
- Linting: ESLint 9.29.0
- Node.js (version 18 or higher)
- npm or yarn
- RushDB account and API credentials
Create a .env file in the root directory with your RushDB credentials:
VITE_RUSHDB_API_TOKEN=your_rushdb_api_token_here
VITE_RUSHDB_URL=your_rushdb_url_here-
Clone the repository or navigate to the project directory:
cd vite-react-useForm -
Install dependencies:
npm install
-
Set up your environment variables (see Environment Setup above)
-
Start the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:5173
npm run dev- Start the development servernpm run build- Build the project for productionnpm run lint- Run ESLint to check for code issuesnpm run preview- Preview the production build locally
src/
├── App.tsx # Main application component with form logic
├── App.css # Application styles
├── db.ts # RushDB configuration
├── main.tsx # Application entry point
├── index.css # Global styles
└── vite-env.d.ts # Vite environment types
The application uses Zod schemas for comprehensive validation:
- Required field validation
- Email format validation
- URL validation for social links
- Minimum/maximum length constraints
- Custom validation messages
Users can dynamically add and remove skills with real-time validation and duplicate prevention.
The form provides immediate feedback with:
- Real-time validation as you type
- Visual error indicators
- Form submission status updates
- Success/error messaging
All form submissions are stored in RushDB with additional metadata:
- Submission timestamp
- User agent information
- Form version tracking
- Fill out the comprehensive form with your information
- Watch real-time validation feedback as you type
- Add multiple skills using the dynamic skills section
- Set your preferences using checkboxes
- Submit the form to see success confirmation
- Data is automatically saved to your RushDB instance
- The form uses
mode: "onChange"for real-time validation - All form fields are strongly typed with TypeScript
- Error handling includes both client-side validation and server errors
- The form resets automatically after successful submission
- Ensure all new code follows the existing TypeScript patterns
- Add appropriate Zod validation for any new form fields
- Test form validation and submission thoroughly
- Update this README if adding new features
This project is provided as an example and learning resource.