Files
effect-fc/packages/docs/docs/intro.md
Julien Valverdé 19527856fb
All checks were successful
Lint / lint (push) Successful in 15s
Add doc intro
2026-02-24 01:54:17 +01:00

3.0 KiB
Raw Blame History

sidebar_position
sidebar_position
1

Effect FC

Welcome to Effect FC a powerful integration of Effect-TS with React 19.2+ that enables you to write function components using Effect generators.

What is Effect FC?

Effect FC allows you to harness the full power of Effect-TS within your React components. Instead of writing traditional React hooks, you can use Effect generators to compose complex, type-safe component logic with built-in error handling, resource management, and dependency injection.

Key Features

  • Effect-TS Integration: Write components using Effect generators for powerful, composable effects
  • Type Safety: Full TypeScript support with Effect's comprehensive type system
  • Resource Management: Automatic cleanup and finalization of resources
  • Dependency Injection: Built-in support for providing dependencies to components
  • React 19.2+ Compatible: Leverages the latest React features

Quick Example

Here's what writing an Effect FC component looks like:

export class Todos extends Component.make("Todos")(function*() {
    const state = yield* TodosState
    const [todos] = yield* useSubscribables(state.ref)

    yield* useOnMount(() => Effect.andThen(
        Console.log("Todos mounted"),
        Effect.addFinalizer(() => Console.log("Todos unmounted")),
    ))

    const TodoFC = yield* Todo

    return (
        <Container>
            <Heading align="center">Todos</Heading>

            <Flex direction="column" align="stretch" gap="2" mt="2">
                <TodoFC _tag="new" />

                {Chunk.map(todos, todo =>
                    <TodoFC key={todo.id} _tag="edit" id={todo.id} />
                )}
            </Flex>
        </Container>
    )
}) {}

Getting Started

Prerequisites

Before using Effect FC, make sure you have:

  • Node.js version 20.0 or above
  • React 19.2 or higher
  • Effect 3.19 or higher

Installation

Install Effect FC and its peer dependencies:

npm install effect-fc effect react

Or with your preferred package manager:

yarn add effect-fc effect react
bun add effect-fc effect react
pnpm add effect-fc effect react

Next Steps

Important Notes

:::info Early Development This library is in early development. While it is mostly feature-complete and usable, expect bugs and quirks. Things are still being ironed out, so ideas and criticisms are welcome! :::

:::warning Known Issues

  • React Refresh doesn't work for Effect FC components yet. Page reload is required to view changes. Regular React components are unaffected. :::

Community & Support

Have questions or want to contribute? We'd love to hear from you! Check out the project repository and feel free to open issues or discussions.