Capxul Docs
How-to guides

Run the SDK in Node

Create and own a Core SDK client in scripts, services, CLIs, and agent backends.

Node consumers use the same root factory as browsers:

import { createCapxulClient } from "@capxul/sdk";

const created = await createCapxulClient({
  publishableKey: process.env.CAPXUL_PUBLISHABLE_KEY!,
  requirement: "counterfactual",
});
if (!created.ok) throw created.error;

const client = created.value;
try {
  // Call domain method bundles here.
} finally {
  await client._internal.close?.();
}

Create one client for a process or bounded request scope; do not create a new client for every domain call. A client closes over its resolved bootstrap and Account requirement.

Deployed readiness

localPrivateKeySigner is available from the packed Node entry:

import { localPrivateKeySigner } from "@capxul/sdk/node";

const signer = localPrivateKeySigner({
  privateKey: process.env.CAPXUL_SIGNER_PRIVATE_KEY! as `0x${string}`,
});

Supply it to the root factory only when the workflow requires deployed readiness.

Session persistence limitation

The root consumer factory currently owns its cache selection and does not accept an authCache override. Although the packed Node entry exports a filesystem cache helper, it cannot be composed into CapxulClientInput today. Treat root-factory Node sessions as process-lifetime state and authenticate again in a new process. This is a tracked API gap, not an invitation to import workspace-only production seams.

On this page