Installation
IC Reactor is compatible with React 18+, and works with TypeScript 5+.
Prerequisites
Section titled “Prerequisites”- Node.js 18 or later for
@ic-reactor/coreand@ic-reactor/react;@ic-reactor/candidrequires Node 20.19.0 or later (the floor of its@noble/hashesdependency), and@ic-reactor/clirequires Node 22.12.0 or later. Each package declares this in itsenginesfield. - A package manager: npm, yarn, pnpm, or bun
Install Packages
Section titled “Install Packages”Most users will want the React package, which includes everything you need:
pnpm add @ic-reactor/react @icp-sdk/core @tanstack/react-querynpm install @ic-reactor/react @icp-sdk/core @tanstack/react-queryyarn add @ic-reactor/react @icp-sdk/core @tanstack/react-querybun add @ic-reactor/react @icp-sdk/core @tanstack/react-queryNon-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:
pnpm add @ic-reactor/core @icp-sdk/core @tanstack/query-corenpm install @ic-reactor/core @icp-sdk/core @tanstack/query-coreyarn add @ic-reactor/core @icp-sdk/core @tanstack/query-corebun add @ic-reactor/core @icp-sdk/core @tanstack/query-coreOptional Tooling
Section titled “Optional Tooling”Make your development easier with our tooling packages:
Vite Plugin
Section titled “Vite Plugin”If you use Vite, this plugin automates code generation and provides zero-config proxy setup.
pnpm add -D @ic-reactor/vite-pluginFor other frameworks or manual control, use the CLI to generate hooks and declarations.
pnpm add -D @ic-reactor/cliInternet Identity (@icp-sdk/auth)
Section titled “Internet Identity (@icp-sdk/auth)”Needed only if you sign users in with Internet Identity. It is an optional
peer dependency of @ic-reactor/react — AuthenticationManager 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.
pnpm add @icp-sdk/auth@^8Bundlers 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:
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 Overview
Section titled “Package Overview”| 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 |
✅ Required • included means it comes with the parent package • Optional for specific features
TypeScript Configuration
Section titled “TypeScript Configuration”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"] }}Generate Declarations
Section titled “Generate Declarations”IC Reactor needs generated canister declarations for end-to-end type safety. You can supply them in three ways:
- Recommended for Vite: use
@ic-reactor/vite-plugin - Recommended for non-Vite or CI: use
@ic-reactor/cli - Manual or existing workflow: keep using your existing generator such as
dfx generateor@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>.jswith theidlFactorydeclarations/<did-basename>.d.tsservice typesdeclarations/<did-basename>.dida copy of the source.didindex.generated.ts— the managed reactor (plus React hooks whentarget: "react"); regenerated on every runindex.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.
Verify Installation
Section titled “Verify Installation”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)Bundler Configuration
Section titled “Bundler Configuration”No additional configuration needed for Vite. Just ensure you have the required polyfills:
import { defineConfig } from "vite"
export default defineConfig({ define: { global: "globalThis", }, optimizeDeps: { esbuildOptions: { define: { global: "globalThis", }, }, },})Next.js
Section titled “Next.js”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 = nextConfigNext Steps
Section titled “Next Steps”Now that you have IC Reactor installed, continue to the Quick Start guide to build your first integration!