How lezuber/conform works
This project is a type-safe form validation library called “conform” that leverages web fundamentals to progressively enhance HTML forms while providing integrations for popular server frameworks like Remix and Next.js. Its purpose is to validate and manage form state both on the client (e.g., with DOM APIs and React hooks) and on the server side, allowing type-safe form handling with schema validation through libraries like Zod and Yup.
Main Components
• Core Library Modules: Separate the library into its key packages:
• conform-dom: Handles core operations such as DOM form handling, form data processing, and submission management.
• conform-react: Provides React integration, context, and hooks for state and field management.
• conform-validitystate: Implements fine-grained subscription and browser-native form validity management.
• conform-yup and conform-zod: Provide schema validation integrations for Yup and Zod respectively.
• Documentation and Guides: The docs directory (with multi-language support) that explains API usage, integration guides (e.g., for UI libraries, accessibility).
• Examples/Playground: Multiple examples (e.g., for Chakra UI, Headless UI, Material UI, Next.js, Remix, etc.) showing how to use the library in various front-end frameworks.
• Tests: A suite that validates both the individual packages and their integrations, ensuring the library’s quality and robustness.
• Build and Configuration: Tools like Rollup, ESLint, Prettier, Husky, and CI/CD workflows (under .github/workflows) that manage the development, testing, and release process.
Relationships and Interactions
• The core module (conform-dom) is the foundation upon which the other packages build.
• The React integration (conform-react) consumes conform-dom’s core functionality and exposes React-friendly APIs.
• The schema integrations (conform-yup and conform-zod) work as plugins/extensions that interface with conform-dom to perform type coercion and constraint validations.
• The test suites and examples validate and demonstrate how all these pieces interact with one another.
• Documentation and example apps (in directories like examples and guide) illustrate the intended usage and integration patterns with external UI libraries and server frameworks.
Architectural Patterns and Design Principles
• Modularity: The architecture is modular and “package‐oriented,” allowing users to pick and choose the integrations they need.
• Progressive Enhancement: Emphasis on adding rich form experiences on top of HTML’s native form behavior.
• Type-Safety & Declarative API Design: Core to the project, with type inference and strong integration with types, particularly for React.
• Clear Separation of Concerns: Each package in packages/ (e.g., conform-dom, conform-react, etc.) is responsible for a distinct set of functionalities.
Final Recommendations
• Link these modules to the examples and documentation, emphasizing the end-to-end flow from form creation in HTML to enhanced form behaviors.
• Data flow from user input (via HTML) to form state updates and validation.
• Dependencies among modules (e.g., React hooks depending on conform-dom’s methods).