Skip to main content

Installation

Usage

1

Set up your Convex dev deployment

Run convex dev to set up your Convex dev deployment.
2

Define your database schema

Not every Effect Schema is valid for use in Confect. See Schema Restrictions for more information about what’s permitted and what’s not.
Define a table — one file per table under confect/tables/, where the filename is the table name (so filenames must be valid JS identifiers and may not start with _). Each file must default-export a Table; codegen reads module.default and applies the filename as the table name. From other modules (e.g. specs), default-import the codegen-emitted wrapper at confect/_generated/tables/<name> to reach the table’s derived Schemas (notes.Doc, notes.Fields).
confect/tables/notes.ts
Codegen will assemble every confect/tables/*.ts into a DatabaseSchema (in confect/_generated/schema.ts) and a Convex deploy SchemaDefinition (in confect/_generated/convexSchema.ts) for you — you never write a confect/schema.ts. It also emits a confect/_generated/id.ts module exporting a type-safe Id constructor (Id("notes")) for cross-table references.
3

Define your Confect API spec

Create a GroupSpec and add some functions to it.
confect/notes.spec.ts
4

Run the codegen command

Generate your app’s confect/_generated/ files.
5

Implement your Confect functions

Create a GroupImpl and implement its functions.
confect/notes.impl.ts
GroupImpl.finalize only typechecks once every function declared by the spec has a corresponding FunctionImpl, so it acts as a per-group completeness check.Run confect codegen again to pick up the new impl.
6

Start your Confect app

Run the confect dev command to generate your app’s Convex functions.
In another terminal, run the convex dev command to start your Convex dev deployment.
7

Call your Confect functions from your React app

Set up the Convex React client and provider.
src/main.tsx
Use Confect’s React hooks alongside your Confect public refs to call your Confect functions.
src/App.tsx

Example project

See a full, working example project here.