Skip to main content
Node actions are like regular actions, but they are executed in the Node.js runtime, so their handlers can use Node’s built-in modules and npm packages that depend on them. You declare a node action group by building its spec with GroupSpec.makeNode() (rather than GroupSpec.make()); that marks the group as Node-runtime, and Confect adds Convex’s "use node" directive to the generated module accordingly. A node action group is otherwise an ordinary group β€” the same colocated .spec.ts/.impl.ts files, following the same naming and nesting conventions.

Node Spec

A node spec uses GroupSpec.makeNode() and one of FunctionSpec.publicNodeAction() or FunctionSpec.internalNodeAction() to define functions.
confect/email.spec.ts

Node Impl

A node impl default-imports its sibling spec and passes the database schema from _generated/schema to FunctionImpl.make and GroupImpl.make β€” exactly like a non-node impl; only the spec differs (GroupSpec.makeNode()). Each handler runs in the Node.js runtime, so it has access to NodeContext services from the @effect/platform package.
confect/email.impl.ts

Calling Node Actions

Node actions are referenced like any other function. A node group at confect/email.spec.ts is reached at refs.public.email.