Installation
IC Reactor is compatible with React 18+, and works with TypeScript 5+.
Prerequisites
Section titled “Prerequisites”- Node.js 18 or later
- 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/cliPackage 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
The generated files typically include:
index.jsor<canister>.jswith theidlFactory<canister>.did.d.tsservice types- an optional generated
index.tsreactor entrypoint when you use IC Reactor tooling
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!