Skip to content
IC Reactor

@ic-reactor/vite-plugin

@ic-reactor/vite-plugin generates the module that candid-core-cli gen writes from a .did file, with @candid-core/cli in a child process, and it sets the ic_env cookie and the /api proxy under vite dev and vite preview. It adds no wrapper files, hooks or reactors.

Its 4 line is published under npm’s beta dist-tag. latest is still the 0.15 plugin of the 3.x line, which generates reactor bindings with @ic-reactor/codegen: see Migrating from 3.x.

Terminal window
npm install --save-exact @candid-core/[email protected]
npm install --save-dev --save-exact @candid-core/[email protected]
npm install --save-dev @ic-reactor/vite-plugin@beta

The package has one entry, @ic-reactor/vite-plugin, in ESM and CommonJS. It exports two names, and there is no other subpath:

Name Kind What it is
icReactor function icReactor(options?) returns the Vite plugin
IcReactorPluginOptions type The options: canisters, injectEnvironment, failOnError
import { icReactor, type IcReactorPluginOptions } from "@ic-reactor/vite-plugin"
import { defineConfig } from "vite"
const options: IcReactorPluginOptions = {
canisters: { icrc1: { didFile: "did/icrc1.did" } },
}
export default defineConfig({ plugins: [icReactor(options)] })
Peer Range
@candid-core/cli exactly 0.2.0
vite ^4.2.0, ^5.0.0, ^6.0.0, ^7.0.0 or ^8.0.0

The CLI is pinned exactly because the plugin runs the CLI your app installs, and that CLI has to pair with the @candid-core/schema runtime the generated modules import. The plugin itself imports no @ic-reactor runtime package, so it can be used with the generated module alone.