@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.
Install
Section titled “Install”npm install --save-exact @meantjs/schema@0.6.0npm install --save-dev --save-exact @meantjs/cli@0.5.1npm install --save-dev @ic-reactor/vite-pluginExports
Section titled “Exports”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.
Read next
Section titled “Read next”- The Vite plugin: options, generation, failures and the local environment in full.
- Getting started: install, generate and make a first read and write.
- Vite wallet:
network: "env"and{ name }targets on a localicpnetwork. - ICRC-1 ledger: three
.didfiles generated into oneoutDir, withinjectEnvironment: false. - @ic-reactor/core and @ic-reactor/react: the runtime packages.