Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/rjdellecese/confect/llms.txt

Use this file to discover all available pages before exploring further.

Introduction to Confect

Confect is a framework that deeply integrates Effect with Convex, enabling you to build type-safe, functional backend applications with the full power of Effect’s ecosystem.

What is Confect?

Confect goes beyond simple Effect bindings for Convex - it’s a comprehensive framework that brings Effect’s schema-driven development, type safety, and functional programming patterns to the Convex platform.

Schema-Driven Development

Define your database schema, function arguments, and return types using Effect’s powerful schema library for end-to-end type safety.

Effect Services

Access Convex platform capabilities through Effect services like DatabaseReader and DatabaseWriter for composable, testable code.

HTTP APIs

Build HTTP APIs using Effect’s HTTP modules with automatic OpenAPI documentation powered by Scalar.

Full-Stack Types

Automatically decode and encode data according to your schemas from client to function to database and back.

Why Confect?

Confect provides several key benefits for developers building Convex applications:

Type Safety Everywhere

With Confect, you define your schemas once using Effect Schema, and they automatically validate data at runtime while providing compile-time types across your entire stack - from React components to database queries.
import { Table } from "@confect/server";
import { Schema } from "effect";

const Users = Table.make(
  "users",
  Schema.Struct({
    username: Schema.String,
    email: Schema.String.pipe(Schema.maxLength(255)),
  })
);

Functional Effect Programming

Leverage Effect’s powerful abstractions for handling errors, managing dependencies, and composing business logic:
import { FunctionImpl } from "@confect/server";
import { Effect } from "effect";

const getUser = FunctionImpl.make(
  api,
  "users",
  "get",
  ({ userId }) =>
    Effect.gen(function* () {
      const reader = yield* DatabaseReader;
      return yield* reader.table("users").get(userId);
    }).pipe(Effect.orDie)
);

Rich Schema Validation

Effect Schema provides runtime validation with detailed error messages, transformations, and composable validators:
const Notes = Table.make(
  "notes",
  Schema.Struct({
    text: Schema.String.pipe(Schema.maxLength(100)),
    tag: Schema.optional(Schema.String),
    author: Schema.optional(
      Schema.Struct({
        role: Schema.Literal("admin", "user"),
        name: Schema.String,
      })
    ),
  })
);

Seamless React Integration

Use Confect’s React hooks for type-safe queries, mutations, and actions:
import { useQuery, useMutation } from "@confect/react";
import refs from "../confect/_generated/refs";

function MyComponent() {
  const notes = useQuery(refs.public.notesAndRandom.notes.list, {});
  const insertNote = useMutation(refs.public.notesAndRandom.notes.insert);
  
  // Fully typed with autocomplete and compile-time checks!
}

Prerequisites

Before using Confect, you should have:
Required Knowledge: Familiarity with both Effect and Convex is essential for working with Confect.

Effect Experience

You should understand:
  • Effect’s core concepts (Effect type, generators, pipe)
  • Effect Schema for validation and transformation
  • Effect Layers for dependency injection
  • Basic functional programming patterns

Learn Effect

Start with the official Effect documentation to learn the fundamentals

Convex Knowledge

You should be familiar with:
  • Convex’s architecture and real-time capabilities
  • Queries, mutations, and actions
  • The Convex development workflow
  • Basic Convex schema and validators

Learn Convex

Read the Convex documentation to understand the platform

Architecture Overview

Confect applications follow a structured pattern:
1

Define Database Schema

Create your database tables using Effect Schema and Confect’s Table.make() API.
2

Specify Functions

Define your queries, mutations, and actions with typed arguments and return values using FunctionSpec.
3

Implement Business Logic

Write your function implementations using Effect and Confect services like DatabaseReader and DatabaseWriter.
4

Generate Types

Run the Confect CLI to generate TypeScript types and React hooks for your frontend.
5

Build Your UI

Use the generated hooks in your React components for fully typed, real-time data access.

Core Packages

Confect is organized into several packages:
PackageDescription
@confect/coreShared specs and schemas used by all packages
@confect/serverBackend bindings and database access services
@confect/reactClient-side React hooks for queries and mutations
@confect/cliCode generation and development tooling

What’s Next?

Quickstart

Build your first Confect application in minutes

Core Concepts

Deep dive into Confect’s core concepts and patterns