Spec
A spec defines the interface of your Confect API. It is made up of group specs and function specs. Each function spec defines the function’s name, arguments schema, and returns schema—but not the function’s logic. Theargs and returns schemas (and an optional error schema) are passed as () => Schema callbacks, evaluated lazily on first invocation.
Specs are built using @confect/core, which means they can be shared between the server and client. This separation is what enables end-to-end schema decoding and encoding: the client knows the exact shape of every function’s arguments and return value without importing any server code.
Each group spec is the default export of a *.spec.ts file. The group’s name comes from the file’s path—its stem for top-level groups, or the dot-joined directory path for nested groups:
confect/notes_and_random/notes.spec.ts
Impl
An impl provides the logic for each function declared in your spec. Each impl is the default export of a*.impl.ts file colocated with its sibling spec. It default-imports that sibling spec, passes it to FunctionImpl.make and GroupImpl.make, and finalizes the resulting layer with GroupImpl.finalize:
confect/notes_and_random/notes.impl.ts
GroupImpl.finalize rejects, at compile time, any pipeline that has not provided a FunctionImpl for every function declared by the spec. This guarantees that the group is fully implemented before it is handed to the generated convex/ module.
Run confect codegen after adding or changing specs and impls.