fp-ts-react

Implements fp-ts functional programming patterns for React state, forms, and data fetching.

1|Updated Aug 17, 2025
One-click install
npx skills add https://github.com/ratnesh-maurya/mdconverter --skill fp-ts-react-ratnesh-maurya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fp-ts-react
Source: https://github.com/ratnesh-maurya/mdconverter/tree/main/.claude/skills/fp-ts-react
Command: npx skills add https://github.com/ratnesh-maurya/mdconverter --skill fp-ts-react-ratnesh-maurya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires fp-ts, fp-ts-react-stable-hooks, @devexperts/remote-data-ts, io-ts, zod.

What problem does it solve? React codebases using fp-ts often struggle with nullable state, scattered form validation errors, boolean-based loading states that allow impossible combinations, and unnecessary re-renders caused by referentially unstable fp-ts values. ## Core Features & Use Cases - Type-Safe State Management: Use Option, Either, TaskEither, and RemoteData to model missing values, failures, and async states without null checks or boolean flags. - Form Validation with Error Accumulation: Collect all validation errors at once using Either's applicative validation, or map errors to individual fields for better UX. - Data Fetching Patterns: Build fetch hooks with TaskEither, chain or parallelize API calls, and render loading/error/success UI with the RemoteData state machine. - Use Case: When building a signup form in a Next.js 15 app, validate name, email, and password with Either, display all field errors at once, then submit via a TaskEither API call rendered through RemoteData states. ## Quick Start Ask the AI to refactor a React component's data fetching and form validation to use fp-ts patterns like Option, Either, TaskEither, and RemoteData.

Frequently Asked Questions about fp-ts-react

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use fp-ts Option for React state management?

Use useState with O.Option<T> instead of null or undefined, then render with O.match to handle both the none and some cases explicitly. Chain nested optional values with O.flatMap and provide defaults with O.getOrElse.

How to validate React forms with fp-ts Either?

Write validators returning Either<string, string>, then combine them with sequenceS and E.getApplicativeValidation to accumulate all errors instead of stopping at the first. Use E.match in the submit handler to display errors or submit valid data.

What is the RemoteData pattern for React data fetching?

RemoteData is a four-state union type: NotAsked, Loading, Failure, or Success. It replaces separate data, loading, and error booleans, making impossible state combinations unrepresentable and forcing exhaustive UI handling via a fold function.

Does fp-ts work with React 19 and Next.js 15?

Yes, fp-ts patterns work with React 18/19 and Next.js 14/15. React 19 features like use(), useActionState, and useOptimistic compose with fp-ts validation, for example running Either-based validation inside a useActionState form action.

Why do fp-ts values cause extra React re-renders?

Constructors like O.some(1) create new object references each render, so useEffect dependency checks see them as changed. Fix this by memoizing with useMemo over raw values, or use fp-ts-react-stable-hooks for equality-based comparisons.

When should I use TaskEither instead of promises in React?

Use TaskEither when an async operation can fail and you want typed errors instead of thrown exceptions. TE.tryCatch wraps fetch calls, TE.flatMap chains dependent requests, and sequenceT with TE.ApplyPar runs requests in parallel.