Skip to content
IC Reactor

Installation

IC Reactor is compatible with React 18+, and works with TypeScript 5+.

  • Node.js 18 or later for @ic-reactor/core and @ic-reactor/react; @ic-reactor/candid requires Node 20.19.0 or later (the floor of its @noble/hashes dependency), and @ic-reactor/cli requires Node 22.12.0 or later. Each package declares this in its engines field.
  • A package manager: npm, yarn, pnpm, or bun

Most users will want the React package, which includes everything you need:

Terminal window
pnpm add @ic-reactor/react @icp-sdk/core @tanstack/react-query

Non-React Projects (Node.js, Svelte, Vue, etc.)

Section titled “Non-React Projects (Node.js, Svelte, Vue, etc.)”

If you’re not using React, install the core package directly:

Terminal window
pnpm add @ic-reactor/core @icp-sdk/core @tanstack/query-core

Make your development easier with our tooling packages:

If you use Vite, this plugin automates code generation and provides zero-config proxy setup.

Terminal window
pnpm add -D @ic-reactor/vite-plugin

Read more about Vite Plugin

For other frameworks or manual control, use the CLI to generate hooks and declarations.

Terminal window
pnpm add -D @ic-reactor/cli

Read more about CLI

Needed only if you sign users in with Internet Identity. It is an optional peer dependency of @ic-reactor/reactAuthenticationManager loads it with a dynamic import(), so nothing breaks when it is absent, but login() will not work until you install it.

@ic-reactor/react requires @icp-sdk/auth v8 (peerDependencies: "^8.0.0"). v7 is no longer supported — the compatibility shim that made it work was removed in 3.12.0.

Terminal window
pnpm add @icp-sdk/auth@^8

Bundlers still resolve that specifier while building the module graph, which happens before any tree-shaking — so a missing peer cannot simply be optimized away. The import sits inside a try block, which webpack-family bundlers treat as declaring an optional dependency: with the peer absent the build succeeds and prints one warning, Module not found: Can't resolve '@icp-sdk/auth/client'. Only the login paths are affected, and they throw an actionable error if they are ever called.

Install the peer to remove the warning, or silence it with ignoreWarnings:

webpack.config.js
module.exports = {
ignoreWarnings: [{ module: /@ic-reactor\/react/, message: /@icp-sdk\/auth/ }],
}
// next.config.js — ignoreWarnings only takes effect inside webpack()
module.exports = {
webpack: (config) => {
config.ignoreWarnings = [
{ module: /@ic-reactor\/react/, message: /@icp-sdk\/auth/ },
]
return config
},
}

The optional-try treatment is webpack-specific — other bundlers may refuse to resolve the missing specifier at build time. If yours does, install the peer, or construct the AuthClient yourself and pass it as authClient to AuthenticationManager, in which case IC Reactor never imports @icp-sdk/auth at all.

With the peer installed, the auth module is code-split into its own async chunk. That chunk is never fetched unless something touches authentication, and its bytes are dropped from the output entirely in apps that never reference AuthenticationManager.

Read more about Authentication

Package Purpose For React For Non-React
@ic-reactor/react React hooks + re-exports core
@ic-reactor/core Core: Reactor, ClientManager, utilities included
@icp-sdk/core IC SDK for agents and Candid
@tanstack/react-query TanStack Query for React
@tanstack/query-core TanStack Query core (caching engine) included
@icp-sdk/auth Internet Identity authentication Optional Optional

✅ Requiredincluded means it comes with the parent package • Optional for specific features

IC Reactor is written in TypeScript and provides first-class type support. Ensure your tsconfig.json includes:

{
"compilerOptions": {
"strict": true,
"moduleResolution": "bundler",
"esModuleInterop": true,
"skipLibCheck": true,
"target": "ES2020",
"lib": ["ES2020", "DOM", "DOM.Iterable"]
}
}

IC Reactor needs generated canister declarations for end-to-end type safety. You can supply them in three ways:

  1. Recommended for Vite: use @ic-reactor/vite-plugin
  2. Recommended for non-Vite or CI: use @ic-reactor/cli
  3. Manual or existing workflow: keep using your existing generator such as dfx generate or @icp-sdk/bindgen

With @ic-reactor/vite-plugin or @ic-reactor/cli, every canister gets its own folder under the output directory (default src/declarations):

  • declarations/<did-basename>.js with the idlFactory
  • declarations/<did-basename>.d.ts service types
  • declarations/<did-basename>.did a copy of the source .did
  • index.generated.ts — the managed reactor (plus React hooks when target: "react"); regenerated on every run
  • index.ts — a stable wrapper that re-exports the generated file and is safe to customize

dfx generate and @icp-sdk/bindgen use their own layout, typically an index.js factory plus a <canister>.did.d.ts service type.

Create a simple test to verify everything is working:

import { ClientManager, Reactor } from "@ic-reactor/react"
import { QueryClient } from "@tanstack/react-query"
const queryClient = new QueryClient()
const clientManager = new ClientManager({ queryClient })
console.log("IC Reactor installed successfully!")
console.log("Network:", clientManager.network)

No additional configuration needed for Vite. Just ensure you have the required polyfills:

vite.config.ts
import { defineConfig } from "vite"
export default defineConfig({
define: {
global: "globalThis",
},
optimizeDeps: {
esbuildOptions: {
define: {
global: "globalThis",
},
},
},
})

For Next.js apps, add to next.config.js:

/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config) => {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
}
return config
},
}
module.exports = nextConfig

Now that you have IC Reactor installed, continue to the Quick Start guide to build your first integration!