Skip to main content
Convex components are configured in convex/convex.config.ts, which is one of the files in the convex/ directory that Confect does not manage. Configure components using the vanilla Convex API.
convex/convex.config.ts
import { defineApp } from "convex/server";
import workpool from "@convex-dev/workpool/convex.config";

const app = defineApp();
app.use(workpool, { name: "workpool" });

export default app;

Referencing components

Component clients (like Workpool) take a component reference. Import the typed components registry that Confect generates at confect/_generated/components.ts:
confect/workpool.ts
import { Workpool } from "@convex-dev/workpool";
import { components } from "./_generated/components";

const pool = new Workpool(components.workpool, {
  maxParallelism: 3,
});
Use this registry rather than the components export of convex/_generated/api, which doesn’t exist yet when confect codegen evaluates your code and so breaks codegen on a clean checkout. Confect’s registry is equivalent, but is derived directly from convex/convex.config.ts, so it is safe to import anywhere in your confect/ directory.
Each component is typed with the ComponentApi type that component packages export from _generated/component.js. Recently published versions of the official @convex-dev/* components all follow this convention; a component that predates it will still work at runtime but won’t get precise types.

Defining functions for components

Some components (such as Workflow, Migrations, and Workpool) expect you to define Convex functions in your project that they can reference. You can integrate these into your Confect spec and impl using plain Convex functions. See the Convex components documentation for details on installing and using components.