Skip to content

React Form MozardMonadic Form Composition for React

Compose complex form flows declaratively using JavaScript Generators

What is Mozard?

React Form Mozard solves common challenges in multi-step form development:

  • Conditional branching: Dynamically alter form flow based on user input
  • State persistence: Maintain form state across navigation and browser sessions
  • Complex validation: Handle interdependent form steps with ease

Mozard leverages JavaScript Generators to provide a declarative approach to form composition:

typescript
*do(step) {
  const profile = yield* step("profile", ProfileForm, {});

  if (profile.age < 18) {
    const consent = yield* step("parentConsent", ParentConsentForm, {});
    return { profile, consent };
  }

  const preferences = yield* step("preferences", PreferencesForm, {});
  return { profile, preferences };
}

This approach eliminates boilerplate state management code while maintaining type safety.