Skip to content

@ic-reactor/vite-plugin

@ic-reactor/vite-plugin generates the module that meant gen writes from a .did file, with @meantjs/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 replaces 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 @meantjs/schema@0.6.0
npm install --save-dev --save-exact @meantjs/cli@0.5.1
npm install --save-dev @ic-reactor/vite-plugin

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, onGenerated
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
@meantjs/cli exactly 0.5.1
@icp-sdk/core ^6.1.0, optional
vite ^4.5.6, ^5.4.12, ^6.0.9, ^7.0.0 or ^8.0.0

Node >=22.12.0, as core and react.

The vite floors are the first release of each major with the fix for CVE-2025-24010. Before it, any website open in the developer’s browser could send requests to the dev server and read the answers, and the plugin’s /api proxy passes those requests on to the local network’s canisters.

The CLI is pinned exactly because the plugin runs the CLI your app installs, and that CLI has to pair with the @meantjs/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. It loads @icp-sdk/core only to fetch a .did from a live canister, when a didFile is not on disk; every app on @ic-reactor/core has it installed already.