Skip to content

The IC Reactor CLI (@ic-reactor/cli) helps you generate React hooks and TypeScript declarations from your Candid files. It’s useful if you’re not using Vite or want more control over the generation process.

bash pnpm add -D @ic-reactor/cli

Initialize the configuration file (ic-reactor.json) in your project root.

Terminal window
npx ic-reactor init

Options:

  • -y, --yes: Skip prompts and use defaults.
  • -o, --out-dir <path>: Output directory for generated hooks (default: src/declarations).

Regenerates hooks and declarations for all configured canisters. Run this whenever your .did files change. It creates an index.ts file in each canister directory with fully typed hooks.

Terminal window
npx ic-reactor generate

Options:

  • -c, --canister <name>: Generate only for a specific canister.
  • --clean: Clean output directory before generating.

The ic-reactor.json file controls the CLI behavior.

{
"outDir": "src/declarations",
"clientManagerPath": "../../clients",
"canisters": {
"backend": {
"didFile": "src/backend/backend.did"
}
}
}
KeyTypeDescription
outDirstringBase output directory for generated files (required).
canistersRecord<string, CanisterConfig>Map of canister names to configurations (required).
clientManagerPathstringPath to a custom ClientManager instance (optional).
KeyTypeDescription
didFilestringPath to the .did file (required).
namestringCanister name.
outDirstringOverride output directory for this canister.
clientManagerPathstringOverride client manager path.
canisterIdstringOptional fixed canister ID.