fp-ts-react
Practical patterns for using fp-ts with React - hooks, state, forms, data fetching. Use when building React apps with functional programming patterns. Works with React 18/19, Next.js 14/15.
npx skills add sickn33/agentic-awesome-skills --skill fp-ts-react --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Implements practical patterns for using fp-ts with React, covering type-safe state with Option, form validation with Either (including collecting all errors and field-level errors), data fetching with TaskEither, a RemoteData pattern for async state, referential stability techniques, and dependency injection via Context using ReaderTaskEither. Also includes React 19 patterns (use() for promises, useActionState, and an outline for useOptimistic). The skill provides concrete code examples and hooks to apply these FP patterns in React applications.
How it works
- Uses Option to represent potentially missing values and demonstrates typical usage with useState and O.match to render UI for present vs. absent values.
- Uses Either for form validation, including examples that collect all errors with sequenceS and E.getApplicativeValidation, as well as field-level errors by building a Partial record of field errors.
- Wraps API calls in TaskEither via fetchJson and demonstrates a custom React hook useFetch that pipes the TE (TaskEither) result through TE.match to set loading, data, and error state data in a React component.
- Demonstrates a RemoteData type with four states (NotAsked, Loading, Failure, Success), plus a hook useRemoteData(fetchFn) that triggers execution and updates state, and a fold-based render approach for UI depending on the current state.
- Addresses referential stability by highlighting that O.some(1) creates new objects each render, suggesting useMemo and an optional stable-hooks package (fp-ts-react-stable-hooks) to compare values using equality rather than reference.
- Shows dependency injection with React Context by defining AppDependencies (api and analytics), creating a DepsContext, AppProvider, and useDeps hook, and then using the dependencies inside components, including a testing example with a mockDeps object.
- Includes React 19 specific patterns:
- use() for promises to suspend data with Suspense.
- useActionState to manage form submission state using an Either-based validation flow.
- Outline of useOptimistic for immediate feedback (text truncated in provided snippet).
- Commands, file names, and tool names are quoted exactly as shown (e.g., "fp-ts-react-stable-hooks", "useStableO", "Option", "Either", "TaskEither").
When to use it
- When building React apps with fp-ts for type-safe state management.
- When handling loading/error/success states in data fetching.
- When implementing form validation with error accumulation.
- When using React 18/19 or Next.js 14/15 with functional patterns.
What it can touch
- Code patterns shown use imports from fp-ts modules like 'fp-ts/Option', 'fp-ts/Either', 'fp-ts/TaskEither', and React hooks from 'react'. It also references optional tool 'fp-ts-react-stable-hooks' and standard React APIs such as useState, useEffect, useMemo, and context APIs. The examples include file content in TypeScript within React components and hooks usage.
Caveats
- License is MIT; risk is safe. The skill emphasizes patterns and sample code but does not guarantee runtime behavior or production readiness beyond demonstrations.
# Functional Programming in React Practical patterns for React apps. No jargon, just code that works. ## When to Use This Skill - When building React apps with fp-ts for type-safe state management - When handling loading/error/success states in data fetching - When implementing form validation with error accumulation - When using React 18/19 or Next.js 14/15 with functional patterns --- ## Quick Reference | Pattern | Use When | |---------|----------| | `Option` | Value might be missing (user not loaded yet) | | `Either` | Operation might fail (form validation) | | `TaskEither` | Async operation might fail (API calls) | | `RemoteData` | Need to show loading/error/success states | | `pipe` | Chaining multiple transformations | --- ## 1. State with Option (Maybe It's There, Maybe Not) Use `Option` instead of `null | undefined` for clearer intent. ### Basic Pattern ```typescript import { useState } from 'react' import * as O from 'fp-ts/Option' import { pipe } from 'fp-ts/function' interface User { id: string name: string email: string } function UserProfile() { // Option says "this might not exist yet" const [user, setUser] = useState<O.Option<User>>(O.none) const handleLogin = (userD
- When to Use This Skill
- Quick Reference
- 1. State with Option (Maybe It's There, Maybe Not)
- Basic Pattern
- Chaining Optional Values
- 2. Form Validation with Either
- Simple Form Validation
- Collecting All Errors (Not Just First One)
- Field-Level Errors (Better UX)
- 3. Data Fetching with TaskEither
- Basic Fetch Hook
- Chaining API Calls
- Parallel API Calls
- 4. RemoteData Pattern (The Right Way to Handle Async State)
npm install fp-ts-react-stable-hooks
What does the fp-ts-react skill do?
Practical patterns for using fp-ts with React - hooks, state, forms, data fetching. Use when building React apps with functional programming patterns. Works with React 18/19, Next.js 14/15.
How do I install it?
Run `npx skills add sickn33/agentic-awesome-skills --skill fp-ts-react --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From sickn33/agentic-awesome-skills, a repository with 44,414 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.