-
Notifications
You must be signed in to change notification settings - Fork 4
Code Generation
b3hr4d edited this page Mar 11, 2026
·
1 revision
IC Reactor supports three declaration-generation paths.
Recommended for Vite apps.
import { defineConfig } from "vite"
import react from "@vitejs/plugin-react"
import { icReactor } from "@ic-reactor/vite-plugin"
export default defineConfig({
plugins: [
react(),
icReactor({
canisters: [{ name: "backend", didFile: "./backend/backend.did" }],
}),
],
})Why use it:
- automatic regeneration on
.didchanges - local
ic_envcookie injection throughicp-cli - best development loop for Vite apps
Recommended for non-Vite apps, CI, or explicit generation workflows.
pnpm exec ic-reactor init
pnpm exec ic-reactor generateThe CLI creates an ic-reactor.json config and generates declarations plus a
typed index.ts entrypoint per canister.
If your project already uses dfx generate or @icp-sdk/bindgen, you can keep
that flow and use the resulting declarations with Reactor or
createActorHooks(...).
Depending on the generator, you will usually get:
- an IDL factory module
- a
*.did.d.tsservice type file - optionally an IC Reactor-generated
index.tsentrypoint with typed hooks
- Vite app: use the Vite plugin
- Next.js or explicit pipeline: use the CLI or your existing manual generator
- custom generation tooling: use
@ic-reactor/codegen